当前位置: 首页>>代码示例>>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;未经允许,请勿转载。