[PyQt] PyQt logger

Adrian Casey mail at agcasey.com
Wed Mar 9 11:19:37 GMT 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 plan to share as much code as possible to the point where the command-line 
interface will  actually invoke the GUI but the GUI will be hidden and the 
command-line options will simply be passed to widgets in the GUI.

I want a flexible, threadsafe logging facility for my application so I plan to 
use python's logging module.  The main reason I like the logging module is  
because I can change the verbosity of logging at runtime.  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 a logging object so 
that instead of sending output to stdout (as in StreamHandler), it emits Qt4 
signals instead.

Thank you.
Adrian Casey.



More information about the PyQt mailing list