當前位置: 首頁>>代碼示例>>Python>>正文


Python logging._levelToName方法代碼示例

本文整理匯總了Python中logging._levelToName方法的典型用法代碼示例。如果您正苦於以下問題:Python logging._levelToName方法的具體用法?Python logging._levelToName怎麽用?Python logging._levelToName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logging的用法示例。


在下文中一共展示了logging._levelToName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: make_logging_level_names_consistent

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import _levelToName [as 別名]
def make_logging_level_names_consistent():
    """Rename the standard library's logging levels to match Twisted's.

    Twisted's new logging system in `twisted.logger` that is.
    """
    for level in list(logging._levelToName):
        if level == logging.NOTSET:
            # When the logging level is not known in Twisted it's rendered as
            # a hyphen. This is not a common occurrence with `logging` but we
            # cater for it anyway.
            name = "-"
        elif level == logging.WARNING:
            # "Warning" is more consistent with the other level names than
            # "warn", so there is a fault in Twisted here. However it's easier
            # to change the `logging` module to match Twisted than vice-versa.
            name = "warn"
        else:
            # Twisted's level names are all lower-case.
            name = logging.getLevelName(level).lower()
        # For a preexisting level this will _replace_ the name.
        logging.addLevelName(level, name) 
開發者ID:maas,項目名稱:maas,代碼行數:23,代碼來源:_common.py

示例2: assemble_global_handler

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import _levelToName [as 別名]
def assemble_global_handler(logger):
        if LoggerFactory.LOG_DIR:
            for level in LoggerFactory.levels:
                if level >= LoggerFactory.LEVEL:
                    level_logger_name = logging._levelToName[level]
                    logger.addHandler(LoggerFactory.get_global_hanlder(level_logger_name, level))
        if LoggerFactory.append_to_parent_log and LoggerFactory.PARENT_LOG_DIR:
            for level in LoggerFactory.levels:
                if level >= LoggerFactory.LEVEL:
                    level_logger_name = logging._levelToName[level]
                    logger.addHandler(LoggerFactory.get_global_hanlder(level_logger_name, level, LoggerFactory.PARENT_LOG_DIR)) 
開發者ID:FederatedAI,項目名稱:FATE,代碼行數:13,代碼來源:log_utils.py

示例3: get_log_levels

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import _levelToName [as 別名]
def get_log_levels():
    """
    Return a list of available log level names
    """
    try:
        level_to_name = logging._levelToName
    except AttributeError:
        level_to_name = dict([(key, logging._levelNames[key])
                              for key in logging._levelNames
                              if isinstance(key, int)])
    for level in sorted(level_to_name):
        yield level_to_name[level] 
開發者ID:2ndquadrant-it,項目名稱:barman,代碼行數:14,代碼來源:utils.py

示例4: pytest_configure

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import _levelToName [as 別名]
def pytest_configure(config):
    """Setup multiprocessing logging for loky testing"""
    if sys.version_info >= (3, 4):
        logging._levelToName[5] = "SUBDEBUG"
    log = log_to_stderr(config.getoption("--loky-verbosity"))
    log.handlers[0].setFormatter(logging.Formatter(
        '[%(levelname)s:%(processName)s:%(threadName)s] %(message)s'))

    warnings.simplefilter('always')

    config.addinivalue_line("markers", "timeout")
    config.addinivalue_line("markers", "broken_pool")
    config.addinivalue_line("markers", "high_memory") 
開發者ID:joblib,項目名稱:loky,代碼行數:15,代碼來源:conftest.py

示例5: logger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import _levelToName [as 別名]
def logger():
    getpid_patch = patch('logging.os.getpid', return_value=111)
    getpid_patch.start()
    time_patch = patch('logging.time.time', return_value=946725071.111111)
    time_patch.start()
    localzone_patch = patch('rfc5424logging.handler.get_localzone', return_value=timezone)
    localzone_patch.start()
    hostname_patch = patch('rfc5424logging.handler.socket.gethostname', return_value="testhostname")
    hostname_patch.start()
    connect_patch = patch('logging.handlers.socket.socket.connect', side_effect=connect_mock)
    connect_patch.start()
    sendall_patch = patch('logging.handlers.socket.socket.sendall', side_effect=connect_mock)
    sendall_patch.start()

    if '_levelNames' in logging.__dict__:
        # Python 2.7
        level_patch = patch.dict(logging._levelNames)
        level_patch.start()
    else:
        # Python 3.x
        level_patch1 = patch.dict(logging._levelToName)
        level_patch1.start()
        level_patch2 = patch.dict(logging._nameToLevel)
        level_patch2.start()

    logging.raiseExceptions = True
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    yield logger

    getpid_patch.stop()
    time_patch.stop()
    localzone_patch.stop()
    hostname_patch.stop()
    connect_patch.stop()
    sendall_patch.stop()

    if '_levelNames' in logging.__dict__:
        # Python 2.7
        level_patch.stop()
    else:
        # Python 3.x
        level_patch1.stop()
        level_patch2.stop()

    Rfc5424SysLogAdapter._extra_levels_enabled = False 
開發者ID:jobec,項目名稱:rfc5424-logging-handler,代碼行數:48,代碼來源:conftest.py


注:本文中的logging._levelToName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。