当前位置: 首页>>代码示例>>Python>>正文


Python MemoryHandler.setFormatter方法代码示例

本文整理汇总了Python中logging.handlers.MemoryHandler.setFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python MemoryHandler.setFormatter方法的具体用法?Python MemoryHandler.setFormatter怎么用?Python MemoryHandler.setFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在logging.handlers.MemoryHandler的用法示例。


在下文中一共展示了MemoryHandler.setFormatter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from logging.handlers import MemoryHandler [as 别名]
# 或者: from logging.handlers.MemoryHandler import setFormatter [as 别名]
    def __init__(self):
        memory_handler = MemoryHandler(self.MEMORY_HANDLER_SIZE)
        memory_handler.setFormatter(Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))

        self.handlers = []
        self.handlers.append(memory_handler)

        self.registered_loggers = {}
开发者ID:juanchitot,项目名称:jaimeboot,代码行数:10,代码来源:logger.py

示例2: make_mem_logger

# 需要导入模块: from logging.handlers import MemoryHandler [as 别名]
# 或者: from logging.handlers.MemoryHandler import setFormatter [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:couchjd,项目名称:playground,代码行数:12,代码来源:Logs.py

示例3: make_mem_logger

# 需要导入模块: from logging.handlers import MemoryHandler [as 别名]
# 或者: from logging.handlers.MemoryHandler import setFormatter [as 别名]
def make_mem_logger(name, to_log, size=8192):
	"""
	Creates 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
开发者ID:afeldman,项目名称:waf,代码行数:15,代码来源:Logs.py

示例4: log_debug

# 需要导入模块: from logging.handlers import MemoryHandler [as 别名]
# 或者: from logging.handlers.MemoryHandler import setFormatter [as 别名]
        else:
            sys.stdout=sys.__stdout__ #old_stdout
            sys.stderr=sys.__stderr__

#adds a stream catcher for display and a memory handler for saving
log_stream=StreamCatch()
logger=getLogger()
display_handler=StreamHandler(stream=log_stream)
display_handler.setLevel(LOGLEVEL)
display_handler.setFormatter(Formatter(LOGFORMATTER))
display_handler.name="StreamCatch"
logger.addHandler(display_handler)

memory_handler=MemoryHandler(MEMBUFFER)
memory_handler.setLevel(LOGLEVEL)
memory_handler.setFormatter(Formatter(LOGFORMATTER))
memory_handler.name="MemoryLog"
logger.addHandler(memory_handler)

log_debug("Started logging")

def make_log_file(log_path, mode='a'):
    """Points memory handler at a particular file to save the log."""
    file_handler = FileHandler(filename=log_path, mode=mode)
    file_handler.setLevel(LOGLEVEL)
    file_handler.setFormatter(Formatter(LOGFORMATTER))
    memory_handler.setTarget(file_handler)

def remove_log_file():
    """closes the log file and removes memory_handler from pointing at it"""
    if memory_handler.target:
开发者ID:priyanka27s,项目名称:TA_software,代码行数:33,代码来源:LOG_functions.py

示例5: test_wording

# 需要导入模块: from logging.handlers import MemoryHandler [as 别名]
# 或者: from logging.handlers.MemoryHandler import setFormatter [as 别名]
        # Original punctuation should be out of the brackets
        self.positive("I am hear!", "I am [here]!")
        # Drop leading and trailing spaces
        self.positive(" their is ", "[there] is")
        # Retain double spaces
        self.positive("their  is", "[there]  is")
        # Drop periods, commas, and semicolons
        self.positive("their is.", "[there] is")
        self.positive("their is,", "[there] is")
        self.positive("their is;", "[there] is")

    def test_wording(self):
        """Verify that wording can be generated without failing"""
        self.positive(
            "Their is and your don't supposed to! (blah) They think their is.")
        logging.debug(self.parser.generate_wording('@@')
                      .encode('ascii', 'replace'))
        # not implemented yet
        self.assertRaises(NotImplementedError,
                          self.parser.generate_wording_long, '')

if __name__ == '__main__':
    stream_null = StringIO()
    logging.basicConfig(stream=stream_null, level=logging.DEBUG)
    handler_stream = StreamHandler(stream=sys.stderr)
    handler_mem = MemoryHandler(1024, target=handler_stream)
    handler_mem.setLevel(logging.DEBUG)
    handler_mem.setFormatter(logging.Formatter())
    logging.getLogger().addHandler(handler_mem)
    unittest.main()
开发者ID:franciscomello,项目名称:grammar,代码行数:32,代码来源:test.py


注:本文中的logging.handlers.MemoryHandler.setFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。