当前位置: 首页>>代码示例>>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;未经允许,请勿转载。