我正在使用Logbook进行日志记录。例如,当我为日志设置级别时,WARNING
它还会记录ERROR
级别日志。我怎样才能将日志记录级别设置为WARNING
.
from logbook import StreamHandler, ERROR, WARNING, CRITICAL, INFO, Logger
import sys
handler = StreamHandler(sys.stdout)
handler.push_application()
log = Logger('demo', WARNING)
log.info("Knock Knock")
# no output
log.error("Knock Knock")
# output : [2017-08-17 09:59:49.133053] ERROR: demo: Knock Knock
log.warning("Knock Knock")
# output : [2017-08-17 09:59:49.133053] WARNING: demo: Knock Knock
我不想log.error
输出任何东西。我怎样才能做到这一点?