logging and PyQt4

Discussion in 'Python' started by Adrian Casey, Mar 14, 2011.

  1. Adrian Casey

    Adrian Casey Guest

    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.
     
    Adrian Casey, Mar 14, 2011
    #1
    1. Advertisements

  2. Adrian Casey

    Vinay Sajip Guest

    On Mar 14, 7:40 am, Adrian Casey <> wrote:
    > 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
     
    Vinay Sajip, Mar 15, 2011
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    0
    Views:
    1,164
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    10,376
    janne
    Sep 10, 2004
  3. Christoph Haas
    Replies:
    0
    Views:
    613
    Christoph Haas
    Jun 12, 2006
  4. Christoph Haas
    Replies:
    1
    Views:
    644
    Vinay Sajip
    Jun 14, 2006
  5. johnny
    Replies:
    1
    Views:
    794
    Dennis Lee Bieber
    Dec 12, 2006
  6. Gal Aviel
    Replies:
    1
    Views:
    586
    Gerard Flanagan
    Mar 4, 2008
  7. Royan
    Replies:
    1
    Views:
    1,740
    Andrea Francia
    Apr 1, 2008
  8. wgw
    Replies:
    1
    Views:
    618
Loading...