logging and PyQt4

Adrian Casey mail at agcasey.com
Mon Mar 14 03:40:07 EDT 2011


I have a multi-threaded PyQt4 application which has both a GUI and command-
line interface.  I am using Qt4's threading because from what I have read, 
it is more efficient than the native python threading module.  Also, given 
most users will probably use the GUI, it seemed to make sense.  

I want a flexible, threadsafe logging facility for my application so I was 
thinking of using python's logging module.  I need a logger that can log to 
the GUI or a terminal depending on how the application is invoked.

So, my question is -:

Is it wise to use python's logging module in conjunction with Qt4 threads?  
If not, what are my options apart from writing my own logging module?

If it is OK, then I would like to know how to subclass the logging class so 
that instead of sending output to stdout (as in StreamHandler), it emits Qt4 
signals instead.

Any help would be appreciated.

Thank you.
Adrian Casey.



More information about the Python-list mailing list