Package grassyknoll :: Package lib :: Module meta :: Class AutoLogger
[hide private]

Class AutoLogger

source code


descriptor that returns a logger named after the class or subclass

Simply do something like:
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
>>> class Foo(object):
...     logger=AutoLogger()
>>> class Bar(Foo):
...     pass
>>> f=Foo()
>>> f.logger.error("I am foo")
ERROR:Foo:I am foo
>>> b=Bar()
>>> b.logger.error("I am bar")
ERROR:Bar:I am bar
>>> Foo.logger.error("This logs from class Foo")
ERROR:Foo:This logs from class Foo
>>> Bar.logger.error("And this is from class Bar")
ERROR:Bar:And this is from class Bar


Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__get__(self, obj, objtype=None) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)