4
我想通過 自定義日誌處理程序或自定義日誌記錄程序類 來創建自定義日誌記錄程序方法,並將日誌記錄分派到不同的目標。如何在Python中的自定義logging.Handler中獲取日誌記錄的級別?
例如:
log = logging.getLogger('application')
log.progress('time remaining %d sec' % i)
custom method for logging to:
- database status filed
- console custom handler showing changes in a single console line
log.data(kindOfObject)
custom method for logging to:
- database
- special data format
log.info
log.debug
log.error
log.critical
all standard logging methods:
- database status/error/debug filed
- console: append text line
- logfile
如果我通過重寫EMIT方法, 我不能distinguishe日誌記錄的水平使用自定義LoggerHandler。 是否有任何其他可能性獲取記錄級別的運行時信息?
class ApplicationLoggerHandler(logging.Handler):
def emit(self, record):
# at this place I need to know the level of the record (info, error, debug, critical)?
有什麼建議嗎?
非常感謝! – koleto 2010-06-17 15:40:13
@ koleto,不客氣! – 2010-06-17 17:28:59