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


Python handlers.MemoryHandler类代码示例

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


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

示例1: __init__

    def __init__(self, when='h', interval=1, backupCount=0):
        """
        Constructor for logging formatter.
        """
        # Formatting string
        format_str = '%(asctime)s - %(levelname)s'
        if TvbProfile.current.cluster.IN_OPERATION_EXECUTION_PROCESS:
            log_file = self.CLUSTER_NODES_LOG_FILE
            if TvbProfile.current.cluster.IS_RUNNING_ON_CLUSTER_NODE:
                node_name = TvbProfile.current.cluster.CLUSTER_NODE_NAME
                if node_name is not None:
                    format_str += ' [node:' + str(node_name) + '] '
            else:
                format_str += ' [proc:' + str(os.getpid()) + '] '
        else:
            log_file = self.WEB_LOG_FILE

        format_str += ' - %(name)s - %(message)s'

        rotating_file_handler = SimpleTimedRotatingFileHandler(log_file, when, interval, backupCount)
        rotating_file_handler.setFormatter(logging.Formatter(format_str))

        MemoryHandler.__init__(self, capacity=self.BUFFER_CAPACITY, target=rotating_file_handler)
        
        
        
        
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:23,代码来源:cluster_handler.py

示例2: __init__

 def __init__(self, capacity, mail_subject):
     MemoryHandler.__init__(self,
                            capacity,
                            flushLevel=logging.ERROR,
                            target=None)
     self.mail_subject = mail_subject
     self.flushed_buffers = []
开发者ID:kangta123,项目名称:easy-websocket,代码行数:7,代码来源:log.py

示例3: __init__

    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,代码行数:8,代码来源:logger.py

示例4: make_mem_logger

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,代码行数:10,代码来源:Logs.py

示例5: make_mem_logger

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,代码行数:13,代码来源:Logs.py

示例6: create_logging_handler_for_collection

def create_logging_handler_for_collection(tempdir, prefix):
    from sys import maxsize
    from os import path
    from logging import FileHandler, DEBUG, Formatter
    from logging.handlers import MemoryHandler
    target = FileHandler(path.join(tempdir, "{}.{}.debug.log".format(prefix, get_timestamp())))
    target.setFormatter(Formatter(**LOGGING_FORMATTER_KWARGS))
    handler = MemoryHandler(maxsize, target=target)
    handler.setLevel(DEBUG)
    try:
        yield handler
    finally:
        handler.close()
开发者ID:pombredanne,项目名称:infi.logs_collector,代码行数:13,代码来源:__init__.py

示例7: __init__

 def __init__(self, target):
     MemoryHandler.__init__(self, 100000, target=target)
     self.setLevel(logging.ERROR)
开发者ID:uhahn,项目名称:openapc-de,代码行数:3,代码来源:openapc_toolkit.py

示例8: make_log_file

            sys.stdout=self
            sys.stderr=self
        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():
开发者ID:priyanka27s,项目名称:TA_software,代码行数:31,代码来源:LOG_functions.py

示例9: getPyphantPath

import os
import os.path
import pkg_resources
from pyphant.core.Helpers import getPyphantPath
LOGDIR = getPyphantPath()
import logging
from logging.handlers import MemoryHandler
logging.basicConfig(level=logging.NOTSET,
                    filename=os.path.join(LOGDIR, u'pyphant.log'),
                    filemode='w',
                    format="%(asctime)s - %(levelname)s:%(name)s:%(thread)"\
                    "d:%(module)s.%(funcName)s(l %(lineno)d):%(message)s")
console = logging.StreamHandler()
console.setLevel(logging.WARNING)
pdmh = MemoryHandler(1000, flushLevel=logging.CRITICAL + 1)
pdmh.setLevel(logging.WARNING)
logging.getLogger('').addHandler(pdmh)
logging.getLogger('').addHandler(console)

import sys
import wx
import wx.aui
import sogl
import pyphant.wxgui2.paramvisualization.ParamVisReg as ParamVisReg
from pyphant.core.H5FileHandler import H5FileHandler
from pyphant.wxgui2 import WorkerRepository
from pyphant.wxgui2 import ConfigureFrame
import platform
from pyphant.core.KnowledgeManager import KnowledgeManager
import webbrowser
开发者ID:GitEdit,项目名称:pyphant1,代码行数:30,代码来源:wxPyphantApplication.py

示例10: __init__

 def __init__(self, capacity, flushLevel=logging.ERROR, target=None):
     MemoryHandler.__init__(self, capacity, flushLevel=flushLevel, target=target)
开发者ID:opsteev,项目名称:iUTF,代码行数:2,代码来源:ilog.py

示例11: test_wording

        # 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,代码行数:30,代码来源:test.py

示例12: __init__

 def __init__(self, capacity=1000000, flushLevel=logging.CRITICAL):
     nh = logging.NullHandler()
     MemoryHandler.__init__(self, capacity,
                            flushLevel=flushLevel, target=nh)
开发者ID:weaverba137,项目名称:hpsspy,代码行数:4,代码来源:test_scan.py

示例13: import

import logging
from logging.handlers import MemoryHandler
from IPython.core.magic import (Magics, magics_class, line_magic)

from collections import deque
logMessageBufferSize = 200
logMessages=deque([], logMessageBufferSize)

class PixiedDustLoggingHandler(logging.Handler):
    def emit(self, record):
        logMessages.append((record.levelno, self.format(record)))

#init pixiedust logging
pixiedustHandler = PixiedDustLoggingHandler()
pixiedustHandler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
memHandler = MemoryHandler(1, target=pixiedustHandler)
memHandler.setLevel(logging.DEBUG)

pixiedustLogger = logging.getLogger("PixieDust")
pixiedustLogger.addHandler(memHandler)
pixiedustLogger.setLevel(logging.DEBUG)

@magics_class
class PixiedustLoggingMagics(Magics):
    @line_magic
    def pixiedustLog(self, arg_s):
        try:
            opts,args = self.parse_options( arg_s, "l:f:m:")
            level = logging.getLevelName( opts.get("l", "INFO").upper() )
            if not isinstance(level, int):
                level = logging.getLevelName("INFO")
开发者ID:ibm-cds-labs,项目名称:pixiedust,代码行数:31,代码来源:pdLogging.py


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