import logg mod_logger logg module_logger class object inst_logger log

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logg
mod_logger = logg.module_logger()
class A(object):
inst_logger = logg.instance_logger()
cls_logger = logg.class_logger()
def __init__(self):
self.inst_logger.info("init :-)")
@classmethod
def meth(cls):
cls.cls_logger.info("class-method")
def func(a=None):
logger = logg.function_logger()
logger.info("a=%r" % a)
## in logs it will looks like
# % python b.py
# 2009-10-06 19:43:46,138 - a.A.0x..cL - INFO - init :-)
# 2009-10-06 19:43:46,146 - a.A - INFO - class-method
# 2009-10-06 19:43:46,147 - a.func - INFO - a=None
# 2009-10-06 19:43:46,147 - a.func - INFO - a=1