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 <[email protected]> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/AB7F41D1-FD08-400D-B80A-01E53BD42D5A%40gmail.com.

Reply via email to