【发布时间】:2021-07-09 18:15:03
【问题描述】:
我正在将一个桌面应用程序从 Python 的标准库日志记录移至 Loguru,并希望在用户界面中有一个包含日志记录信息的文本框。
有没有办法连接到 Loguru 错误级别日志记录,允许将日志消息发送到回调函数?这将允许我使用最新的错误消息更新用户界面。例如,
from loguru import logger
def error_callback(msg: str):
# Do something with the error message
pass
logger.add_callback(error_callback) # <-- Does something like this exist?
# So when I do this...
logger.error("Oh noes")
# ... the callback is called with the argument `"Oh noes"`
【问题讨论】:
标签: python logging callback notifications loguru