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


Python logging.getLevelName方法代码示例

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


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

示例1: test_connect_api_from_file

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def test_connect_api_from_file(driver_wrapper):
    # Mock data
    expected_driver = None

    # Change driver type to api and configure again
    root_path = os.path.dirname(os.path.realpath(__file__))
    os.environ["Config_prop_filenames"] = os.path.join(root_path, 'conf', 'api-properties.cfg')
    driver_wrapper.configure(ConfigFiles())
    del os.environ["Config_prop_filenames"]

    # Connect and check that the returned driver is None
    assert driver_wrapper.connect(maximize=False) == expected_driver  # Check that the wrapper has been configured
    assert driver_wrapper.config.get('Driver', 'type') == ''
    assert driver_wrapper.config.get('Jira', 'enabled') == 'false'
    logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
    assert logging.getLevelName(logger.level) == 'DEBUG' 
开发者ID:Telefonica,项目名称:toolium,代码行数:18,代码来源:test_driver_wrapper.py

示例2: test_configure_logger_no_changes

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def test_configure_logger_no_changes(driver_wrapper):
    # Configure logger
    os.environ["Config_log_filename"] = 'logging.conf'
    driver_wrapper.configure_logger()
    logger = logging.getLogger('selenium.webdriver.remote.remote_connection')

    # Modify property
    new_level = 'INFO'
    logger.setLevel(new_level)
    assert logging.getLevelName(logger.level) == new_level

    # Trying to configure again
    driver_wrapper.configure_logger()

    # Configuration has not been initialized
    assert logging.getLevelName(logger.level) == new_level 
开发者ID:Telefonica,项目名称:toolium,代码行数:18,代码来源:test_driver_wrapper_logger.py

示例3: function_invoker

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def function_invoker(event):
    if __version__ != event['pywren_version']:
        raise Exception("WRONGVERSION", "PyWren version mismatch",
                        __version__, event['pywren_version'])

    if event['log_level']:
        cloud_logging_config(event['log_level'])
    log_level = logging.getLevelName(logger.getEffectiveLevel())
    custom_env = {'PYWREN_FUNCTION': 'True',
                  'PYTHONUNBUFFERED': 'True',
                  'PYWREN_LOGLEVEL': log_level}
    os.environ.update(custom_env)
    config = event['config']
    num_invokers = event['invokers']
    invoker = FunctionInvoker(config, num_invokers, log_level)
    invoker.run(event['job_description']) 
开发者ID:pywren,项目名称:pywren-ibm-cloud,代码行数:18,代码来源:invoker.py

示例4: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def __init__(self, gateway):
        self.current_log_level = 'INFO'
        super().__init__(logging.getLevelName(self.current_log_level))
        self.setLevel(logging.getLevelName('DEBUG'))
        self.__gateway = gateway
        self.activated = False
        self.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - [%(filename)s] - %(module)s - %(lineno)d - %(message)s'))
        self.loggers = ['service',
                        'extension',
                        'converter',
                        'connector',
                        'tb_connection'
                        ]
        for logger in self.loggers:
            log = logging.getLogger(logger)
            log.addHandler(self.__gateway.main_handler)
            log.debug("Added remote handler to log %s", logger) 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:19,代码来源:tb_logger.py

示例5: run_mqttwarn

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def run_mqttwarn():

    # Script name (without extension) used as last resort fallback for config/logfile names
    scriptname = os.path.splitext(os.path.basename(sys.argv[0]))[0]

    # Load configuration file
    config = load_configuration(name=scriptname)

    # Setup logging
    setup_logging(config)
    logger.info("Starting {}".format(scriptname))
    logger.info("Log level is %s" % logging.getLevelName(logger.getEffectiveLevel()))

    # Handle signals
    signal.signal(signal.SIGTERM, cleanup)
    signal.signal(signal.SIGINT, cleanup)

    # Bootstrap mqttwarn.core
    bootstrap(config=config, scriptname=scriptname)

    # Connect to broker and start listening
    connect() 
开发者ID:jpmens,项目名称:mqttwarn,代码行数:24,代码来源:commands.py

示例6: test_loglevel_default

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def test_loglevel_default(default, mocker, runner):
    from covimerage import cli
    from covimerage.logger import logger

    if default:
        mocker.patch.object(logger, 'level', getattr(logging, default))
    else:
        default = 'INFO'
    reload(cli)

    result = runner.invoke(cli.main, ['-h'])

    assert logging.getLevelName(logger.level) == default
    lines = result.output.splitlines()
    assert lines, result
    idx = lines.index('  -l, --loglevel [error|warning|info|debug]')
    indent = ' ' * 34
    assert lines[idx+1:idx+3] == [
        indent + 'Set logging level explicitly (overrides',
        indent + u'-v/-q).  [default:\xa0%s]' % (default.lower(),),
    ]
    assert result.exit_code == 0 
开发者ID:Vimjas,项目名称:covimerage,代码行数:24,代码来源:test_logging.py

示例7: get_configuration

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def get_configuration():
    """
    get a configuration (snapshot) that can be used to call configure
    snapshot = get_configuration()
    configure(**snapshot)
    """
    root = getLogger()
    name_levels = [('', logging.getLevelName(root.level))]
    name_levels.extend(
        (name, logging.getLevelName(logger.level))
        for name, logger
        in root.manager.loggerDict.items()
        if hasattr(logger, 'level')
    )

    config_string = ','.join('%s:%s' % x for x in name_levels)

    return dict(config_string=config_string, log_json=SLogger.manager.log_json) 
开发者ID:QuarkChain,项目名称:pyquarkchain,代码行数:20,代码来源:slogging.py

示例8: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def __init__(self, terminalwriter, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._original_fmt = self._style._fmt
        self._level_to_fmt_mapping = {}

        levelname_fmt_match = self.LEVELNAME_FMT_REGEX.search(self._fmt)
        if not levelname_fmt_match:
            return
        levelname_fmt = levelname_fmt_match.group()

        for level, color_opts in self.LOGLEVEL_COLOROPTS.items():
            formatted_levelname = levelname_fmt % {
                "levelname": logging.getLevelName(level)
            }

            # add ANSI escape sequences around the formatted levelname
            color_kwargs = {name: True for name in color_opts}
            colorized_formatted_levelname = terminalwriter.markup(
                formatted_levelname, **color_kwargs
            )
            self._level_to_fmt_mapping[level] = self.LEVELNAME_FMT_REGEX.sub(
                colorized_formatted_levelname, self._fmt
            ) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:25,代码来源:logging.py

示例9: setLevel

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def setLevel(level):
    """Set logging level for the main logger."""
    level = level.lower().strip()
    imdbpyLogger.setLevel(LEVELS.get(level, logging.NOTSET))
    imdbpyLogger.log(imdbpyLogger.level, 'set logging threshold to "%s"',
                    logging.getLevelName(imdbpyLogger.level))


#imdbpyLogger.setLevel(logging.DEBUG)


# It can be an idea to have a single function to log and warn:
#import warnings
#def log_and_warn(msg, args=None, logger=None, level=None):
#    """Log the message and issue a warning."""
#    if logger is None:
#        logger = imdbpyLogger
#    if level is None:
#        level = logging.WARNING
#    if args is None:
#        args = ()
#    #warnings.warn(msg % args, stacklevel=0)
#    logger.log(level, msg % args) 
开发者ID:skarlekar,项目名称:faces,代码行数:25,代码来源:_logging.py

示例10: test_params_and_looping

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def test_params_and_looping(self):
        levels = ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL")
        f = StringIO()
        going = gogo.Gogo(low_hdlr=gogo.handlers.fileobj_hdlr(f))
        logger1 = going.get_logger("area1")
        logger2 = gogo.Gogo().get_logger("area2")

        logger1_msg = "A debug message\nAn info message"
        logger1.debug("A debug message")
        logger1.info("An info %s", "message")
        f.seek(0)
        nt.assert_equal(f.read().strip(), logger1_msg)
        logger2_msg = ""

        for level in [getattr(logging, l) for l in levels]:
            name = logging.getLevelName(level)
            logger2_msg += "%s message\n" % name
            logger2.log(level, "%s %s", name, "message")
            # TODO: lookup yielding from a nose test

        nt.assert_equal(logger2_msg.strip(), sys.stdout.getvalue().strip()) 
开发者ID:reubano,项目名称:pygogo,代码行数:23,代码来源:test_main.py

示例11: update_logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def update_logger(self, logger: logging.Logger=None):
        if logger is None:
            logger = logging.root

        self._log_level = self.log_level if isinstance(self.log_level, int) else logging.getLevelName(self.log_level)

        if logger is logging.root:
            self._log_format = self.log_format.format(
                PEER_ID=self.peer_id[:8] if self.peer_id != "RadioStation" else self.peer_id,
                CHANNEL_NAME=self.channel_name
            )

            self._update_log_output_type()
            self._update_handlers(logger)

            if self.log_color:
                self._update_log_color_set(logger)
                for handler in logger.handlers:
                    if isinstance(handler, logging.StreamHandler):
                        handler.addFilter(self._root_stream_filter)
        else:
            logger.setLevel(self._log_level)

        if self.log_monitor:
            sender.setup('loopchain', host=self.log_monitor_host, port=self.log_monitor_port) 
开发者ID:icon-project,项目名称:loopchain,代码行数:27,代码来源:configuration.py

示例12: __exit__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def __exit__(self, exc_type, exc_value, tb):
        """
        This is a modified version of TestCase._AssertLogsContext.__exit__(...)
        """
        self.logger.handlers = self.old_handlers
        self.logger.propagate = self.old_propagate
        self.logger.setLevel(self.old_level)
        if exc_type is not None:
            # let unexpected exceptions pass through
            return False

        if self.watcher.records:
            msg = 'logs of level {} or higher triggered on {}:\n'.format(
                logging.getLevelName(self.level), self.logger.name)
            for record in self.watcher.records:
                msg += 'logger %s %s:%i: %s\n' % (record.name, record.pathname,
                                                  record.lineno,
                                                  record.getMessage())

            self._raiseFailure(msg) 
开发者ID:Qiskit,项目名称:qiskit-aer,代码行数:22,代码来源:common.py

示例13: _create_logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def _create_logger(
    name: str, target: Union[logging.Logger, str, None], level: str, sys_default: Any
) -> logging.Logger:
    if isinstance(target, logging.Logger):
        return target
    elif target is not None:
        logger = logging.getLogger(name)
        logger.propagate = False
        logger.handlers = []
        if target == "-":
            logger.addHandler(logging.StreamHandler(sys_default))
        else:
            logger.addHandler(logging.FileHandler(target))
        logger.setLevel(logging.getLevelName(level.upper()))
        return logger
    else:
        return None 
开发者ID:pgjones,项目名称:hypercorn,代码行数:19,代码来源:logging.py

示例14: add_args

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def add_args(self, parser):
        parser.add_argument("-s", "--set_of_rules", default="IMS",
                            help="set of rules (defaul=\"IMS\"")
        parser.add_argument("-a", "--splitter_address", default="127.0.1.1",
                            help="Splitter address")
        parser.add_argument("-p", "--splitter_port",
                            default=Peer_DBS.splitter[1], type=int,
                            help="Splitter port (default={})"
                            .format(Peer_DBS.splitter[1]))
        parser.add_argument("-m", "--peer_port", default=0, type=int,
                            help="Monitor port (default={})".format(Peer_DBS.peer_port))
        if __debug__:
            parser.add_argument("--loglevel",
                                default=logging.ERROR,
                                help="Log level (default={})"
                                .format(logging.getLevelName(logging.ERROR)))
            logging.basicConfig(format="%(message)s - %(asctime)s - %(name)s - %(levelname)s") 
开发者ID:P2PSP,项目名称:simulator,代码行数:19,代码来源:monitor.py

示例15: setLevel

# 需要导入模块: import logging [as 别名]
# 或者: from logging import getLevelName [as 别名]
def setLevel(self, level_tag):
        """
        Sets the logging level
        levelStr (str) - a string describing the desired logging level
                        'INFO', 'DEBUG', 'WARNING', also 'NOTSET'
        """
        self.out.setLevel(logging.getLevelName(level_tag)) 
开发者ID:uptake,项目名称:numpynet,代码行数:9,代码来源:loggit.py


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