當前位置: 首頁>>代碼示例>>Python>>正文


Python handlers.MemoryHandler方法代碼示例

本文整理匯總了Python中logging.handlers.MemoryHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python handlers.MemoryHandler方法的具體用法?Python handlers.MemoryHandler怎麽用?Python handlers.MemoryHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logging.handlers的用法示例。


在下文中一共展示了handlers.MemoryHandler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: buffered_hdlr

# 需要導入模塊: from logging import handlers [as 別名]
# 或者: from logging.handlers import MemoryHandler [as 別名]
def buffered_hdlr(target=None, capacity=4096, level="error", **kwargs):
    """A memory buffered log handler

    Args:
        target (obj): The target logger handler (default stdout).

        capacity (int): The buffer size (default 4096).

        level (string): The min event level required to flush buffer
            (default: error).

    Returns:
        New instance of :class:`logging.handlers.MemoryHandler`

    Examples:
        >>> buffered_hdlr()  # doctest: +ELLIPSIS
        <...MemoryHandler...>
    """
    target = target or logging.StreamHandler(sys.stdout)
    return hdlrs.MemoryHandler(capacity, level.upper(), target) 
開發者ID:reubano,項目名稱:pygogo,代碼行數:22,代碼來源:handlers.py

示例2: __init__

# 需要導入模塊: from logging import handlers [as 別名]
# 或者: from logging.handlers import MemoryHandler [as 別名]
def __init__(self, locale=None, target=None):
        """Initialize a TranslationHandler

        :param locale: locale to use for translating messages
        :param target: logging.Handler object to forward
                       LogRecord objects to after translation
        """
        # NOTE(luisg): In order to allow this handler to be a wrapper for
        # other handlers, such as a FileHandler, and still be able to
        # configure it using logging.conf, this handler has to extend
        # MemoryHandler because only the MemoryHandlers' logging.conf
        # parsing is implemented such that it accepts a target handler.
        handlers.MemoryHandler.__init__(self, capacity=0, target=target)
        self.locale = locale 
開發者ID:openstack,項目名稱:oslo.i18n,代碼行數:16,代碼來源:log.py

示例3: make_mem_logger

# 需要導入模塊: from logging import handlers [as 別名]
# 或者: from logging.handlers import MemoryHandler [as 別名]
def make_mem_logger(name,to_log,size=8192):
	from logging.handlers import MemoryHandler
	logger=logging.getLogger(name)
	hdlr=MemoryHandler(size,target=to_log)
	formatter=logging.Formatter('%(message)s')
	hdlr.setFormatter(formatter)
	logger.addHandler(hdlr)
	logger.memhandler=hdlr
	logger.setLevel(logging.DEBUG)
	return logger 
開發者ID:MOSAIC-UA,項目名稱:802.11ah-ns3,代碼行數:12,代碼來源:Logs.py

示例4: shouldFlush

# 需要導入模塊: from logging import handlers [as 別名]
# 或者: from logging.handlers import MemoryHandler [as 別名]
def shouldFlush(self, record: logging.LogRecord) -> bool:
        """
        Check for record at the flushLevel or higher.
        Implementation is mostly taken from `logging.handlers.MemoryHandler`
        """
        return record.levelno >= self.flushLevel  # type: ignore # pytype: disable=attribute-error 
開發者ID:komuw,項目名稱:naz,代碼行數:8,代碼來源:log.py

示例5: emit

# 需要導入模塊: from logging import handlers [as 別名]
# 或者: from logging.handlers import MemoryHandler [as 別名]
def emit(self, record: logging.LogRecord) -> None:
        """
        Emit a record.
        Append the record. If shouldFlush() tells us to, call flush() to process
        the buffer.

        Implementation is taken from `logging.handlers.MemoryHandler`
        """
        self._heartbeat()

        if record.levelno >= self.targetLevel:
            self.buffer.append(record)
        if self.shouldFlush(record):
            self.flush() 
開發者ID:komuw,項目名稱:naz,代碼行數:16,代碼來源:log.py


注:本文中的logging.handlers.MemoryHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。