[wxPython-users] wxLog and python logging module

Robin Dunn robin at alldunn.com
Tue Feb 26 13:06:51 PST 2008


Randall Smith wrote:
> What's the best way to handle logging with wxpython?  I think I'd like 
> to use Python's standard logging module, but wouldn't I then be missing 
> out on wx's logging?  Is there a way to pass off wx's logging to 
> Python's such that LogError goes to logging.error, LogWarning to 
> logging.warning, etc?

Yes, you can create a custom log target class that forwards the messages 
to the logging module.  There is an example of a log class in the demo 
in Main.py, however instead of overriding DoLogString you probably want 
to override DoLog so you can be passed the log level value in addition 
to the message.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list