我正在尝试是否有可能从内存中获取日志消息的历史记录(而不是通过读取文件)。
例如:
#!/usr/bin/env python3
import logging
logging.basicConfig(level=logging.INFO)
logging.info("One")
logging.info("Two")
logging.info("Three")
#madeup method I'd like
logging.log_history()
["One", "Two", "Three"]
# It doesn't have to return a list of strings
# that was just to explain conceptually.
是否可以从内存中的某处获取已记录消息的历史记录?
动机
希望在发生某些故障情况时通过电子邮件发送所有日志。