Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19822
| References | <CANy1k1jD_2E2Di2BgzmisnsT6BoFBGNH87M+0MT63UBE-Qsk6Q@mail.gmail.com> |
|---|---|
| Date | 2012-02-03 04:50 +0000 |
| Subject | Re: Use logging level across application and modules |
| From | Jason Friedman <jason@powerpull.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5391.1328244633.27778.python-list@python.org> (permalink) |
> Base module: http://pastebin.com/nQCG5CRC > Another module: http://pastebin.com/FFzCCjwG > Application: http://pastebin.com/370cWJtT > > I have a module that will provide base functionality, such as logging > and authentication. > I have other specialized modules that provide additional > functionality. One module will provide database connections, another > information about users and groups, etc. > I have an application script that uses the base module and one or more > specialized modules. > > I want to allow the user to select a preferred logging level. That is > easy to do by passing that level as an argument to base.get_logger(). > However, the application also uses the other module; how do I set the > logging level there to match the user's preference? I figured a way to do this. In the base module I created a global variable loglevel. I set the logging level according to that value. I set the variable from my application script. Because of the memoization of the get_logger() call, the other modules get that same loglevel value.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Use logging level across application and modules Jason Friedman <jason@powerpull.net> - 2012-02-03 04:50 +0000
csiph-web