python类MemoryHandler()的实例源码

log.py 文件源码 项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def log_register(log_name):
    """
    Acquire a logger object, initialized with the global level and output options

    :param log_name: logger name (as in `logging.getLogger`), will be prefixed to log lines
    :return: A `logging.Logger` instance.
    """
    logger = logging.getLogger(log_name)
    logger.setLevel(settings.LOG_LEVEL)

    if _enable_stdout:
        _add_stream_handler(logger)
    if _log_filename:
        _add_file_handler(logger)
    if not _log_filename and not _enable_stdout:
        # Prevent 'No handlers could be found' spam
        logger.addHandler(MemoryHandler(0))

    _loggers.add(logger)
    return logger
Logs.py 文件源码 项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码 阅读 43 收藏 0 点赞 0 评论 0
def make_mem_logger(name, to_log, size=8192):
    """
    Create a memory logger to avoid writing concurrently to the main logger
    """
    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
Logs.py 文件源码 项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def make_mem_logger(name, to_log, size=8192):
    """
    Create a memory logger to avoid writing concurrently to the main logger
    """
    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
Logs.py 文件源码 项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def make_mem_logger(name, to_log, size=8192):
    """
    Create a memory logger to avoid writing concurrently to the main logger
    """
    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
gettextutils.py 文件源码 项目:python-kingbirdclient 作者: openstack 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
gettextutils.py 文件源码 项目:eclcli 作者: nttcom 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号