Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38629
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Subject | Logging within a class |
| Date | 2013-02-11 01:26 +0000 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1615.1360546087.2939.python-list@python.org> (permalink) |
Within __init__ I setup a log with self.log = logging.getLogger('foo') then add a
console and filehandler which requires the formatting to be specified. There a few
methods I setup a local log object by calling getChild against the global log object.
This works fine until I need to adjust the formatter for a few. With this style, I need
to redefine the handlers, so basically setup logging again.
I tried to get around this by using basicConfig and simply re-specifying format inside
the few methods, but it didn't work.
How does one accomplish this most elegantly so I can define one log instance with
the appropriate general console and file handlers in my class, then simply override
the formatter for both handlers they use in a couple methods?
Thanks!
jlc
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Logging within a class "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-02-11 01:26 +0000
csiph-web