Created attachment 203030 [details] Patch As discussed in email.
*** Bug 236701 has been marked as a duplicate of this bug. ***
Changing the default nut upslog time format to include time, temperature and other data is a POLA violation. This will result in more PRs asking to have this removed. It will not be included.
No infrastructure exists to create ${PREFIX}/etc/syslog.d ${PREFIX}/etc/newsyslog.conf.d. How do you propose a package create these directories? Should they be deleted after nut is uninstalled? If yes, what if some other package creates them. How would you deal with that? Adding the infrastructure to FreeBSD ports to handle this would be outside of the scope of this PR. I really cannot see implementing this. Unless these issues are resolved this PR cannot go forward. Sorry.
With respect to the log format.. Running upslog says.. format string defaults to: %TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage% %VAR ups.load% [%VAR ups.status%] %VAR ups.temperature% %VAR input.frequency% Which is what I used for the default in nut_upslog.in. With respect to the directory creation - I found net-snmp uses the newsyslog directory, its port does.. .if ${PORT_OPTIONS:MNEWSYSLOG} @${MKDIR} ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d ${INSTALL_DATA} ${FILESDIR}/net-snmp.conf ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/ .endif The net-snmp plist has the file but not the directory (so I presume it won't be deleted on removal either). I think it is a defect that those directories aren't created by default but this PR can't change that.
I can't say I'm enamoured with syslog.conf.d and friends. Regarding restating the default format string, should the upline change the default format we would be required to chase that, probably through a PR. A case construct should suffice. Regarding whether syslog.conf.d, looks like it needs to be added. I'll create a phab review to add it. I'll take some time tomorrow to commit this, with the format string check in a case construct.
Created attachment 203062 [details] Improved newsyslog file I just noticed my newsyslog file was broken, the attached version works properly..
(In reply to Cy Schubert from comment #5) OK, thanks - I wasn't very enamoured with that approach either for the same reason.
Created attachment 203063 [details] with optional formatting
The patch makes the time format optional, fixes /var/log/nut creation, includes the newsyslog file.
Patch looks good, thanks.
A commit references this bug: Author: cy Date: Sat Mar 23 19:34:08 UTC 2019 New revision: 496686 URL: https://svnweb.freebsd.org/changeset/ports/496686 Log: Move default log location so it can be rotated without root privileges. Add syslog.conf and newsyslog.conf files for installation into their respective .d directories in $PREFIX. Allow upslog log format to be customized. PR: 236700 Submitted by: Daniel O'Connor <darius@dons.net.au> (90%) Changes: head/sysutils/nut/Makefile head/sysutils/nut/files/nut.newsyslog head/sysutils/nut/files/nut.syslog head/sysutils/nut/files/nut_upslog.in head/sysutils/nut/pkg-plist
(In reply to commit-hook from comment #11) 12.0 amd64: ===> Staging rc.d startup script(s) ===> Installing for nut-2.7.4_10 ===> Checking if nut is already installed ===> Registering installation for nut-2.7.4_10 pkg-static: Unable to access file /tmp/work/usr/ports/sysutils/nut/work/stage/usr/local/etc/newsyslog.conf.d/nut.conf:No such file or directory pkg-static: Unable to access file /tmp/work/usr/ports/sysutils/nut/work/stage/usr/local/etc/syslog.d/nut:No such file or directory pkg-static: lstat(/tmp/work/usr/ports/sysutils/nut/work/stage/var/log/nut/): No such file or directory *** Error code 74 OPTIONS_FILE_UNSET+=AVAHI OPTIONS_FILE_UNSET+=BASH OPTIONS_FILE_UNSET+=CGI OPTIONS_FILE_UNSET+=DOCS OPTIONS_FILE_UNSET+=NEON OPTIONS_FILE_UNSET+=PDU OPTIONS_FILE_SET+=SERIAL OPTIONS_FILE_SET+=SNMP OPTIONS_FILE_SET+=USB OPTIONS_FILE_SET+=IPMI_OFF OPTIONS_FILE_UNSET+=IPMIPSU OPTIONS_FILE_UNSET+=FREEIPMI OPTIONS_FILE_SET+=SSL_OFF OPTIONS_FILE_UNSET+=OPENSSL OPTIONS_FILE_UNSET+=NSS
(In reply to VVD from comment #12) This should be fixed in 496766: https://svnweb.freebsd.org/ports?view=revision&revision=496766
(In reply to Romain Tartière from comment #13) Thanks, it work now.
The port should create ${PREFIX}/etc/syslog.d/ if it doesn't exist. # make install ===> Installing for nut-2.7.4_13 ===> Checking if nut is already installed ===> Registering installation for nut-2.7.4_13 Installing nut-2.7.4_13... cp: /usr/local/etc/syslog.d/nut: No such file or directory ===> SECURITY REPORT: Please also consider fixing `portlint -C` warnings.