Logging in Python

aha aquil.abdullah at gmail.com
Tue Feb 10 12:50:27 EST 2009


Hello All,

I have an application where logging may need to be configured in
multiple places.  I've used the Python Logging Framework for sometime,
but I'm still not sure how to test if logging has configured.  For
example, I have modules A, B, and C.

Below is some pseudo code...
moduleA

class A(object):
  def __init__(self):
    ...

startLogging(config):
  # Configure logging
  # global logger
  ...

moduleB
import moduleA
from myconfig import MyConfig
class B(object):
  def __init__(self):
    # self.config = MyConfig()
    # if logging has started [HOW DO YOU DO THIS?]
    #   self.logger = logging.getLogger("moduleB")
    # else
    #   self.logger = moduleA.startLogging(self.config)
    # moduleA.startLogging
    ...

Where I need help is determining if a logger has already been
configured.  Any advice?

Aquil



More information about the Python-list mailing list