记录
constants的目标是成为一个好的logging公民,在
伐木树。
所有对logger方法的调用都会公开一个名为method的额外logrecord键。
当日志级别设置为info时,它只记录一条有用的消息。>>> import sys
>>> import logging
>>> logging.basicConfig(level=logging.INFO,
... stream=sys.stdout,
... format='%(levelname)s %(name)s.%(method)s %(message)s')
>>> consts = constants.Constants() # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
INFO constants.load
variable: __CONSTANTS__,
filename: constants.ini,
environment: a_section,
constants: {...}
在调试级别,它变得有点噪音。>>> logging.root.setLevel(logging.DEBUG)
>>> debug_me = consts.just_for_me # doctest: +ELLIPSIS
DEBUG constants.__getattr__ begin (..., 'just_for_me') {}
DEBUG constants.__getitem__ begin (..., 'just_for_me') {}
DEBUG constants.cast begin ('5.0',) {}
DEBUG constants.cast end 5.0
DEBUG constants.__getitem__ end 5.0
DEBUG constants.__getattr__ end 5.0