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


Groups > comp.lang.python > #38629 > unrolled thread

Logging within a class

Started by"Joseph L. Casale" <jcasale@activenetwerx.com>
First post2013-02-11 01:26 +0000
Last post2013-02-11 01:26 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Logging within a class "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-02-11 01:26 +0000

#38629 — Logging within a class

From"Joseph L. Casale" <jcasale@activenetwerx.com>
Date2013-02-11 01:26 +0000
SubjectLogging within a class
Message-ID<mailman.1615.1360546087.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web