QueueLogger
是一个用于后台日志记录的工具。它用于将日志消息存储在一个队列中,以便在后台进行处理和记录。文章来源:https://www.toymoban.com/news/detail-518191.html
下面是他的代码文章来源地址https://www.toymoban.com/news/detail-518191.html
# Code to implement asynchronous logging from a background thread
#
# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, logging.handlers, threading, queue, time
# Class to forward all messages through a queue to a background thread
class QueueHandler(logging.Handler):
def __init__(self, queue):
logging.Handler.__init__(self)
self.queue = queue
def emit(self, record):
try:
self.format(record)
record.msg = record.message
record.args = None
record.exc_info = None
self.queue.put_nowait(record)
except Exception:
self.handleError(record)
# Class to poll a queue in a background thread and log each message
class QueueListener(logging.handler
到了这里,关于Klipper 源码解析-queuelogger的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!