Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18871

Re: Two questions about logging

Date 2012-01-12 11:28 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: Two questions about logging
References <7dabf43f-3814-47b6-966a-1439f56548b5@i6g2000vbk.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.4677.1326364162.27778.python-list@python.org> (permalink)

Show all headers | View raw


Matthew Pounsett wrote:
> [snip]
>
> Second, I'm trying to get a handle on how libraries are meant to
> integrate with the applications that use them.  The naming advice in
> the advanced tutorial is to use __name__ to name loggers, and to allow
> log messages to pass back up to the using application's logger for
> processing, but these two pieces of advice seem contradictory.. since
> log messages only pass back up to the root if the loggers are named
> hierarchically.
>
> [snip]
>
> So, given this state of affairs, how is a library author to use
> loggers, given that he or she can't know how authors who use the
> library will name their logger objects?  In the above example, what
> would the author of bar.py do to hook up bar's logger with foo's,
> without knowing in advance what foo's logger will be named?
>
>
> Thanks very much for any suggestions, or pointers to documentation
> that I've missed.
>   

All loggers share at least one parent : the root logger. In the standard 
way of using the loggers, the root logger is *the* logger responsible of 
processing logs.


Considering that extlib is an external library from anApp, and intlib an 
internal library to the anApp application:

People may expect logs that way:

anApp.extlib : INFO : a log message
anApp.intlib : INFO : another message

However, what will happen is :

extlib : INFO : message from the external lib
anApp.intlib : INFO : message from the internal lib

As you mentioned in your post, there is no way to 'attach' an external 
lib to your application since the external lib knows nothing about the 
application, but there is no need to attach it actually.


JM

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Two questions about logging Matthew Pounsett <matt.pounsett@gmail.com> - 2012-01-11 18:19 -0800
  Re: Two questions about logging Roy Smith <roy@panix.com> - 2012-01-11 21:34 -0500
    Re: Two questions about logging Matthew Pounsett <matt.pounsett@gmail.com> - 2012-01-11 19:31 -0800
  Re: Two questions about logging Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-01-12 11:28 +0100
  Re: Two questions about logging K Richard Pixley <rich@noir.com> - 2012-01-12 17:03 -0800
    Re: Two questions about logging Matthew Pounsett <matt.pounsett@gmail.com> - 2012-01-14 18:03 -0800
  Re: Two questions about logging Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-01-15 17:03 -0800

csiph-web