simplified logging stanza doesn’t work and shows type conversion fix needed.
details follow...

using that simplified stanza in weewx.conf gives runtime error:

  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py",
 line 381, in resolve
    name = s.split('.')
AttributeError: 'NoneType' object has no attribute 'split'

adding class line back into config viz:

[Logging]
#  [[loggers]]
#    [[[root]]]
#      level = DEBUG
#      propogate = True
#      handlers = syslog, rotate
  [[handlers]]
    [[[rotate]]]
#      level = DEBUG
#      formatter = standard
      class = logging.handlers.RotatingFileHandler
      filename = /tmp/weewx.log
#      maxBytes = 10000000
#      backupCount = 2

does not give immediate runtime error
but also adds no logging messages to /tmp/weewx.log

RotatingFileHandler documentation says defaults for maxBytes and backupCount 
are zero
and either of these being zero means logging is not done.
experimentation shows documentation is correct i.e. this config does not work
therefore both maxBytes and backupCount must be definable to be non-zero
so we need the type conversion fix

note: i am using /tmp/weewx.log here because i am presently fiddling with new 
version on test system and don’t want weewxd running rampant with root 
privilege. at least, not yet :-)


> On 3 May 2020, at 5:07 am, Tom Keffer <[email protected]> wrote:
> 
> Great ideas! Thanks for your thoughts.
> 
> 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.
> 
> -tk
> 
> 
> On Sat, May 2, 2020 at 8:05 AM Graham Eddy <[email protected] 
> <mailto:[email protected]>> wrote:
> i think we all agree that syslog on macos is a lost cause.
> the corollary is that pointing python logging at syslog (via 
> logging.handlers.SysLogHandler) is doomed
> 
> i accept that syslog works fine on most platforms, but it is not feasible for 
> macos
> but there is the simple alternative for macos users of using a different 
> handler:
> 
> i patched log_dict in bin/weeutil/logger.py to add a 
> logging.handlers.RotatingFileHandler and it worked fine.
> adding it via weewx.conf gives a type conversion error that seems simple to 
> fix.
> with the fix, i would suggest this be added to the macos installation 
> instructions for user to add to weewx.conf (or make it part of the 
> installation process)
> 
> details follow...
> 
> weewx.conf (yes, using that ‘root’ hack introduced to work around a ConfigObj 
> limitation):
> 
> [Logging]
>   [[loggers]]
>     [[[root]]]
>       level = DEBUG
>       propogate = True
>       handlers = syslog, rotate
>   [[handlers]]
>     [[[rotate]]]
>       level = DEBUG
>       formatter = standard
>       class = logging.handlers.RotatingFileHandler
>       filename = /tmp/weewx.log
>       maxBytes = 10000000
>       backupCount = 2

-- 
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/DB9C3A14-40D2-4B9A-9604-19ED16BC9BAB%40gmail.com.

Reply via email to