logging and PyQt4

A

Adrian Casey

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.
 
V

Vinay Sajip

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, threadsafeloggingfacility for my application so I was
thinking of using python'sloggingmodule.  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'sloggingmodule in conjunction with Qt4 threads?  
If not, what are my options apart from writing my ownloggingmodule?

If it is OK, then I would like to know how to subclass theloggingclass 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.

Logging certainly works well with PyQt4 in multi-threaded
applications, though of course it's based on Python's threading API
rather than Qt's. To direct logging output to a GUI, it would be
appropriate to develop a Qt/PyQt-aware handler class (derived from
logging.Handler) to do the Qt interfacing.

Regards,

Vinay Sajip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top