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


Python logging.level方法代碼示例

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


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

示例1: set_logger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def set_logger():
    logging.level = logging.DEBUG
    logFormatter = \
        logging.Formatter("%(asctime)s %(levelname)s %(message)s")
    rootLogger = logging.getLogger()
    rootLogger.setLevel(logging.DEBUG)
    logfile = '/tmp/ansibullbot.log'
    fileHandler = logging.FileHandler("{0}/{1}".format(
            os.path.dirname(logfile),
            os.path.basename(logfile))
    )
    fileHandler.setFormatter(logFormatter)
    rootLogger.addHandler(fileHandler)
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler) 
開發者ID:ansible,項目名稱:ansibullbot,代碼行數:18,代碼來源:meta_component_dump.py

示例2: convert_level

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def convert_level(level):
    if not level:
        return None
    _valid_levels = [
        logging.DEBUG,
        logging.INFO,
        logging.WARNING,
        logging.ERROR,
        logging.CRITICAL,
    ]
    if level in _valid_levels:
        return level
    if level.lower() == "info":
        return logging.INFO
    elif level.lower() == "debug":
        return logging.DEBUG
    elif level.lower() == "warning":
        return logging.WARNING
    elif level.lower() == "error":
        return logging.ERROR
    elif level.lower() == "critical":
        return logging.CRITICAL
    raise ValueError(
        "Wrong log level use one of the following : {}".format(_valid_levels)
    ) 
開發者ID:ChristianTremblay,項目名稱:BAC0,代碼行數:27,代碼來源:notes.py

示例3: create_logger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def create_logger(name, level=logging.INFO):
    """Get the Strawberry Fields module specific logger and configure it if needed.

    Configuration only takes place if no user configuration was applied to the
    logger. Therefore, the logger is configured if and only if the following
    are true:

    - the logger has WARNING as effective level,
    - the level of the logger was not explicitly set,
    - no handlers were added to the logger.

    As the root logger has a WARNING level by default, any module specific
    logger will inherit the same as effective level.

    The default handler that is used for configuration writes to the standard
    error stream and uses a datetime and level formatter.

    Args:
        name (str): the name of the module for which the logger is being created
        level (logging.level): the logging level to set for the logger
    """
    logger = logging.getLogger(name)

    effective_level_inherited = logger.getEffectiveLevel() == logging.WARNING
    level_not_set = not logger.level
    no_handlers = not logging_handler_defined(logger)

    if effective_level_inherited and level_not_set and no_handlers:
        logger.setLevel(level)
        logger.addHandler(default_handler)

    return logger 
開發者ID:XanaduAI,項目名稱:strawberryfields,代碼行數:34,代碼來源:logger.py

示例4: set_log_level

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def set_log_level(level, handler=None):
    """ Set both vspk and Bambou log level to the given level

        Args:
            level (logging.level): a logging level
            handler (logging.Handler): a logging handler

        Notes:
            if no handler is provided, it will automatically create a new StreamHandler.

        Examples:
            >>> set_log_level(logging.INFO)
            >>> set_log_level(logging.DEBUG, logging.Streamhandler())
            >>> set_log_level(logging.ERROR)

    """

    from bambou import bambou_logger, pushcenter_logger

    if handler is None:
        handler = logging.StreamHandler()

    bambou_logger.setLevel(level)
    bambou_logger.addHandler(handler)

    pushcenter_logger.setLevel(level)
    pushcenter_logger.addHandler(handler)

    logger.setLevel(level)
    logger.addHandler(handler) 
開發者ID:nuagenetworks,項目名稱:vspk-python,代碼行數:32,代碼來源:utils.py

示例5: set_logger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def set_logger(debug=False, logfile=None):

    logFormatter = \
            logging.Formatter("%(asctime)s %(levelname)s %(process)d %(filename)s:%(funcName)s:%(lineno)d %(message)s")
    rootLogger = logging.getLogger()

    if debug:
        logging.level = logging.DEBUG
        rootLogger.setLevel(logging.DEBUG)
    else:
        logging.level = logging.INFO
        rootLogger.setLevel(logging.INFO)

    if logfile:
        try:
            logdir = os.path.dirname(logfile)
            if logdir and not os.path.isdir(logdir):
                os.makedirs(logdir)
            fileHandler = WatchedFileHandler(logfile)
            fileHandler.setFormatter(logFormatter)
            rootLogger.addHandler(fileHandler)
        except Exception as e:
            pass

    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler) 
開發者ID:ansible,項目名稱:ansibullbot,代碼行數:29,代碼來源:logs.py

示例6: set_logger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def set_logger():
    logging.level = logging.DEBUG

    logFormatter = \
        logging.Formatter("%(asctime)s %(levelname)s %(message)s")
    rootLogger = logging.getLogger()
    rootLogger.setLevel(logging.DEBUG)
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler) 
開發者ID:ansible,項目名稱:ansibullbot,代碼行數:12,代碼來源:matching_test.py

示例7: main

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def main():

    logging.level = logging.DEBUG
    logFormatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
    rootLogger = logging.getLogger()
    rootLogger.setLevel(logging.DEBUG)
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler)

    scraper = Scraper() 
開發者ID:ansible,項目名稱:ansibullbot,代碼行數:13,代碼來源:notifications_study.py

示例8: __init__

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def __init__(self, name=None):
        self.logger = logging.getLogger(name or self.Default_Name)
        self.level = logging.DEBUG if self.config.getboolean("Base", "debug") else logging.INFO
        self.logger.setLevel(self.level)
        self.add_handler(self.console_headler) 
開發者ID:fieryd,項目名稱:PKURunningHelper,代碼行數:7,代碼來源:class_.py

示例9: console_headler

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def console_headler(self):
        console_headler = logging.StreamHandler(sys.stdout)
        console_headler.setLevel(self.level)
        console_headler.setFormatter(self.format)
        return console_headler 
開發者ID:fieryd,項目名稱:PKURunningHelper,代碼行數:7,代碼來源:class_.py

示例10: __init__

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def __init__(self,
                 level,
                 named_levels=None,
                 format_string=None,
                 additional_fields=None):
        self.level = level
        # Any false values passed for named_levels should instead be treated as
        # an empty dictionary i.e. no special log levels
        self.named_levels = named_levels or {}
        # Any false values for format string should use the default instead
        self.format_string = format_string or LoggingConfig._default_log_format
        self.additional_fields = additional_fields 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:14,代碼來源:logging_config.py

示例11: setup_logging

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def setup_logging(self):
        """ Establishes the base logging using the appropriate filter
        attached to the console/stream handler.
        """
        console_handler = logging.StreamHandler()
        request_logging.assign_request_filter(console_handler,
                                              self.additional_fields)
        logging.basicConfig(level=self.level,
                            format=self.format_string,
                            handlers=[console_handler])
        for handler in logging.root.handlers:
            handler.setFormatter(RedactionFormatter(handler.formatter))
        logger = logging.getLogger(__name__)
        logger.info('Established logging defaults')
        self._setup_log_levels() 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:17,代碼來源:logging_config.py

示例12: _setup_log_levels

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import level [as 別名]
def _setup_log_levels(self):
        """Sets up the logger levels for named loggers

        :param named_levels: dict to set each of the specified
            logging levels.
        """
        for logger_name, level in self.named_levels.items():
            logger = logging.getLogger(logger_name)
            logger.setLevel(level)
            LOG.info("Set %s to use logging level %s", logger_name, level) 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:12,代碼來源:logging_config.py


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