I like your fix better. Added in commit 6348741 <https://github.com/weewx/weewx/commit/6348741c64f55c5b2d34d9b9c70a5ed0b6d55c7f> .
I also made the rotating log handler the default for MacOS. One problem I've discovered: if you 'declare' a handler, then the logging facility goes ahead and instantiates it, whether or not you actually use it. That means the program crashes when it tries to create /var/log/weewx.log unless its run with sudo privileges. So, for non-Mac systems, I took the handler back out, and put instructions on how to declare it in the wiki documentation <https://bit.ly/2StYSHb>. -tk On Sun, May 3, 2020 at 12:11 AM Graham Eddy <graham.e...@gmail.com> wrote: > woops! i missed your reference to replacement weeutil/logger.py… > putting that in place, it works fine on macos. > it achieves the two things i was after: logs entries in a file (a basic > function missing from weewx on macos for such a long time!), and allows > customising message formats > > i have two critiques about this fix: > > (1) linux would want [syslog] handlers only but macos would want > [rotate] for default. easiest is to default correctly for one in the code > and override it in weewx.conf for the other (applied either by user or > installation script). if both enabled, harmless (if not duplicating entries > in one logfile on linux) but wasteful > > (2) shim approach is per- logging handler class only. would be pretty > easy for python user to add another shim in user/extensions.py but… > alternatively, do the string->int conversions e.g. add after line 130 in > weeutil/logger.py “log_config['Logging'].walk(_fix)” something like: > > def _intify_string_leaf(section, key): > > if isinstance(section[key], str): > # The value is a string... > try: > value = int(section[key]) > except ValueError: > pass > else: > # ... looks like an int, so make it one > section[key] = value > log_config['Logging'].walk(_intify_string_leaf) > > (this works.) conversely, intifying all leaves could have unintended > consequences... > > thanks for all that! cheers > > On 3 May 2020, at 5:07 am, Tom Keffer <tkef...@gmail.com> wrote: > > Try this version of weeutil/logger.py. It includes a shim that does the > proper type conversion before passing on arguments to > logging.handlers.RotatingFileHandler. > > To use should be as simple as adding this to weewx.conf (alas, NOT TESTED): > > [Logging] > [[loggers]] > [[[root]]] > handlers = syslog, rotate > [[handlers]] > [[[rotate]]] > filename = /tmp/weewx.log > > By default, it logs to /var/log/weewx.log. Hence, the need to override > that option if you want to log to /tmp/weewx.log. > > > -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to weewx-user+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/AB7F41D1-FD08-400D-B80A-01E53BD42D5A%40gmail.com > <https://groups.google.com/d/msgid/weewx-user/AB7F41D1-FD08-400D-B80A-01E53BD42D5A%40gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEAunFHwK8QTVrsDhbPONif7Z_8i5L4jWn8O1g52dtW7rA%40mail.gmail.com.