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

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

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. Christoph Haas
    Replies:
    0
    Views:
    481
    Christoph Haas
    Jun 12, 2006
  2. Christoph Haas
    Replies:
    1
    Views:
    486
    Vinay Sajip
    Jun 14, 2006
  3. Harshad

    Drag and Drop with PyQt4

    Harshad, Aug 25, 2006, in forum: Python
    Replies:
    2
    Views:
    1,253
    Harshad
    Aug 26, 2006
  4. johnny
    Replies:
    1
    Views:
    673
    Dennis Lee Bieber
    Dec 12, 2006
  5. wgw
    Replies:
    1
    Views:
    487
Loading...

Share This Page