我有一个Logger对象,具有自定义日志级别支持(假设TRACE)。 我正在使用LogAdapter将上下文信息添加到传递给日志记录调用的参数中。
由于LogAdapter对象不了解自定义日志级别功能,该如何调用?
def get_logger():
# It will return a logger object which has a custom log level TRACE
# It will also add a function, trace() in logger for custom level logging
logger = get_logger()
logger2 = logging.LoggerAdapter(logger,{'instance_id':'some random string'})
logger.trace('some log') # It will work
logger2.trace('Some log') # It will not work
# One possible approach to log TRACE level
logger2.log(TRACE,"New trace") # It will work
答案 0 :(得分:0)
您可以像在 [,1] [,2] [,3]
[1,] 0.00022500 0.0002625 0.00044625
[2,] 0.00026250 0.0006250 0.00000000
[3,] 0.00044625 0.0000000 0.00122500
函数中为trace
实例所做的那样,将自定义函数LoggerAdapter
添加到Logger
类中。像这样:
get_logger