logging module usage

Discussion in 'Python' started by mennis, Mar 30, 2011.

  1. mennis

    mennis Guest

    I am working on a library for controlling various appliances in which
    I use the logging module. I'd like some input on the basic structure
    of what I've done. Specifically the logging aspect but more general
    comments are welcome. I'm convinced I mis-understand something but
    I'm not sure what. I've posted a version of the library at github.

    :mennis/otto.git
    http://github.com/mennis/otto
    Ian
     
    mennis, Mar 30, 2011
    #1
    1. Advertising

  2. mennis

    Vinay Sajip Guest

    On Mar 30, 3:49 pm, mennis <> wrote:
    > I am working on a library for controlling various appliances in which
    > I use theloggingmodule.  I'd like some input on the basic structure
    > of what I've done.  Specifically theloggingaspect but more general
    > comments are welcome.  I'm convinced I mis-understand something but
    > I'm not sure what.  I've posted a version of the library at github.
    >
    > :mennis/otto.githttp://github.com/mennis/otto
    > Ian


    From a quick glance over your code, looking only at the logging
    perspective:

    It's fine to use the Django-like approach to provide better
    compatibility with Python versions < 2.5.

    Your use of an extra level is also OK, but other applications and
    tools won't know about your extra level, which could limit
    interoperability. If your application is completely self contained,
    however, that should be fine.

    You don't really need to hold loggers as instance attributes in
    objects - they are effectively singletons.

    The convention is to use logger = getLogger(__name__), that way you
    don't have to change your code to rename loggers if you move modules
    around in a package.

    Not sure why you are doing logging.disable() in code, this means that
    you can't change the verbosity using configuration files.

    You don't appear to be using the logger.exception() method in
    exception handlers, thereby not putting tracebacks in the log.

    You don't add a NullHandler to the root logger of your top-level
    package, which you should.

    I see you're using Python 2.x, but you may nevertheless find it useful
    to look at the logging docs for Python 3.2. These have been split into
    reference docs and HOWTOs, rather than the somewhat monolithic
    approach taken in the 2.x docs.

    Regards,

    Vinay Sajip
     
    Vinay Sajip, Mar 31, 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. Stefan Siegl
    Replies:
    0
    Views:
    962
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    9,501
    janne
    Sep 10, 2004
  3. rh0dium
    Replies:
    2
    Views:
    344
    rh0dium
    Aug 4, 2005
  4. Christoph Haas
    Replies:
    0
    Views:
    454
    Christoph Haas
    Jun 12, 2006
  5. Christoph Haas
    Replies:
    1
    Views:
    458
    Vinay Sajip
    Jun 14, 2006
Loading...

Share This Page