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


Python logging.Handler方法代码示例

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


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

示例1: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, host, port):
        """
        Initializes the handler with a specific host address and port.

        When the attribute *closeOnError* is set to True - if a socket error
        occurs, the socket is silently closed and then reopened on the next
        logging call.
        """
        logging.Handler.__init__(self)
        self.host = host
        self.port = port
        self.sock = None
        self.closeOnError = False
        self.retryTime = None
        #
        # Exponential backoff parameters.
        #
        self.retryStart = 1.0
        self.retryMax = 30.0
        self.retryFactor = 2.0 
开发者ID:war-and-code,项目名称:jawfish,代码行数:22,代码来源:handlers.py

示例2: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, host, port):
        """
        Initializes the handler with a specific host address and port.

        The attribute 'closeOnError' is set to 1 - which means that if
        a socket error occurs, the socket is silently closed and then
        reopened on the next logging call.
        """
        logging.Handler.__init__(self)
        self.host = host
        self.port = port
        self.sock = None
        self.closeOnError = 0
        self.retryTime = None
        #
        # Exponential backoff parameters.
        #
        self.retryStart = 1.0
        self.retryMax = 30.0
        self.retryFactor = 2.0 
开发者ID:glmcdona,项目名称:meddle,代码行数:22,代码来源:handlers.py

示例3: set_formatter

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def set_formatter(self, handler_id, formatter):
        """Set the formatter of the specified handler.

        Parameters
        ----------
        handler_id : unicode
            Id of the handler whose formatter shoudl be set.

        formatter : Formatter
            Formatter for the handler.

        """
        handlers = self._handlers
        handler_id = str(handler_id)
        if handler_id in handlers:
            handler, _ = handlers[handler_id]
            handler.setFormatter(formatter)

        else:
            logger = logging.getLogger(__name__)
            logger.warning('Handler {} does not exist')

    # ---- Private API --------------------------------------------------------

    # Mapping between handler ids and handler, logger name pairs. 
开发者ID:Exopy,项目名称:exopy,代码行数:27,代码来源:plugin.py

示例4: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, topic_arn):
        logging.Handler.__init__(self)
        self.client = boto3.client("sns")
        self.topic_arn = topic_arn 
开发者ID:servian,项目名称:aws-auto-remediate,代码行数:6,代码来源:sns_logging_handler.py

示例5: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, distutils_log=log):
        logging.Handler.__init__(self)
        self.log = distutils_log
        # Basic numeric table
        self.level_table = {
            logging.CRITICAL: distutils_log.FATAL,
            logging.ERROR: distutils_log.ERROR,
            logging.WARNING: distutils_log.WARN,
            logging.INFO: distutils_log.INFO,
            logging.DEBUG: distutils_log.DEBUG,
        }
        self.setFormatter(logging.Formatter('%(message)s')) 
开发者ID:calmjs,项目名称:calmjs,代码行数:14,代码来源:command.py

示例6: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, db):
        """
        Constructor
        @param db: ['host','port','dbuser', 'dbpassword', 'dbname'] 
        @return: mySQLHandler
        """
        
        logging.Handler.__init__(self)
        self.db = db
        # Try to connect to DB

        # Check if 'log' table in db already exists
        result = self.checkTablePresence()
        # If not exists, then create the table
        if not result:
            try:
                conn=MySQLdb.connect(host=self.db['host'],port=self.db['port'],user=self.db['dbuser'],passwd=self.db['dbpassword'],db=self.db['dbname'])
            except _mysql_exceptions, e:
                raise Exception(e)
                exit(-1)
            else:         
                cur = conn.cursor()
                try:
                    cur.execute(mySQLHandler.initial_sql)
                except _mysql_exceptions as e:
                    conn.rollback()
                    cur.close()
                    conn.close()
                    raise Exception(e)
                    exit(-1)
                else:
                    conn.commit()
                finally:
                    cur.close()
                    conn.close() 
开发者ID:thelectronicnub,项目名称:redditswapbot,代码行数:37,代码来源:mySQLHandler.py

示例7: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, uri):
        logging.Handler.__init__(self)
        RelationalMixin.__init__(self, uri) 
开发者ID:laurivosandi,项目名称:certidude,代码行数:5,代码来源:mysqllog.py

示例8: handleError

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def handleError(self, record):
        """
        Handle an error during logging.

        An error has occurred during logging. Most likely cause -
        connection lost. Close the socket so that we can retry on the
        next event.
        """
        if self.closeOnError and self.sock:
            self.sock.close()
            self.sock = None        #try to reconnect next time
        else:
            logging.Handler.handleError(self, record) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:15,代码来源:handlers.py

示例9: close

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def close(self):
        """
        Closes the socket.
        """
        self.acquire()
        try:
            if self.sock:
                self.sock.close()
                self.sock = None
            logging.Handler.close(self)
        finally:
            self.release() 
开发者ID:war-and-code,项目名称:jawfish,代码行数:14,代码来源:handlers.py

示例10: to_berny_log

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def to_berny_log(pyscf_log):
    '''Adapter to allow pyberny to use pyscf.logger
    '''
    class PyscfHandler(logging.Handler):
        def emit(self, record):
            pyscf_log.info(record.getMessage())

    log = logging.getLogger('{}.{}'.format(__name__, id(pyscf_log)))
    log.addHandler(PyscfHandler())
    log.setLevel('INFO')
    return log 
开发者ID:pyscf,项目名称:pyscf,代码行数:13,代码来源:berny_solver.py

示例11: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, errprinter):
        logging.Handler.__init__(self)
        self.errprinter = errprinter 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:5,代码来源:util.py

示例12: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, saveto=None, *args, **kwargs):
        self.saveto = saveto
        logging.Handler.__init__(self, *args, **kwargs) 
开发者ID:binux,项目名称:pyspider,代码行数:5,代码来源:log.py

示例13: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def __init__(self, *args, **kwargs):
        self.queries = []
        logging.Handler.__init__(self, *args, **kwargs) 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:5,代码来源:test_utils.py

示例14: pytest_sessionstart

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def pytest_sessionstart(self, session):
        handler = Handler()
        logging.root.addHandler(handler)
        yield 
开发者ID:openSUSE,项目名称:salt-toaster,代码行数:6,代码来源:conftest.py

示例15: test_good_config_file

# 需要导入模块: import logging [as 别名]
# 或者: from logging import Handler [as 别名]
def test_good_config_file(tmp_path):
    cfg = get_config_from_file(tmp_path, GOOD_CONFIG)

    # Pass config to EventLog
    e = EventLog(config=cfg)

    # Assert the 
    assert len(e.handlers) > 0
    assert isinstance(e.handlers[0], logging.Handler) 
开发者ID:jupyter,项目名称:telemetry,代码行数:11,代码来源:test_eventlog.py


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