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


Python config.fileConfig方法代码示例

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


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

示例1: _setup_logging

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import fileConfig [as 别名]
def _setup_logging(self, config):
        log_config_file = config[u'log'][u'config_file']
        self._logger.info(u'Logging configuration file: ' + log_config_file)

        try:
            logging.config.fileConfig(log_config_file)
        except Exception:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stderr)
            raise PanoptesConfigurationError(
                    u'Could not instantiate logger with logging configuration provided in file "%s": (%s) %s' % (
                        log_config_file, exc_type, exc_value))

        # Create a filter to rate limit logs so that a misconfiguration or failure does not make the disk I/O go
        # beserk or fill up the disk space. We do this in code instead if configuration for two reasons:
        # - It enforces a filter on every handler, so no chance of messing them up in configuration
        # - We use fileConfig (nof dictConfig) to setup our logging and fileConfig does not support filter configuration
        throttle = RateLimitingFilter(rate=config[u'log'][u'rate'], per=config[u'log'][u'per'],
                                      burst=config[u'log'][u'burst'])

        # Apply the filter to all handlers. Note that this would be a shared filter across ALL logs generated by this
        # process and thus the rate/burst should be set appropriately high
        for handler in logging._handlerList:
            # _handlerList is a list of weakrefs, so the object returned has to be dereferenced
            handler().addFilter(throttle) 
开发者ID:yahoo,项目名称:panoptes,代码行数:27,代码来源:configuration_manager.py

示例2: load_configuration

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import fileConfig [as 别名]
def load_configuration(config_file=DEFAULT_CONFIG_FILE):
    """
    Loads logging configuration from the given configuration file.

    :param config_file:
        the configuration file (default=/etc/package/logging.conf)
    :type config_file: str
    """
    if not os.path.exists(config_file) or not os.path.isfile(config_file):
        msg = '%s configuration file does not exist!', config_file
        logging.getLogger(__name__).error(msg)
        raise ValueError(msg)

    try:
        config.fileConfig(config_file, disable_existing_loggers=False)
        logging.getLogger(__name__).info(
            '%s configuration file was loaded.', config_file)
    except Exception as e:
        logging.getLogger(__name__).error(
            'Failed to load configuration from %s!', config_file)
        logging.getLogger(__name__).debug(str(e), exc_info=True)
        raise e 
开发者ID:storj,项目名称:storj-python-sdk,代码行数:24,代码来源:log_config.py

示例3: logging_file_config

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import fileConfig [as 别名]
def logging_file_config(self, config_file):
        """
        Setup logging via the logging module's fileConfig function with the
        specified ``config_file``, if applicable.

        ConfigParser defaults are specified for the special ``__file__``
        and ``here`` variables, similar to PasteDeploy config loading.
        """
        parser = ConfigParser.ConfigParser()
        parser.read([config_file])
        if parser.has_section('loggers'):
            config_file = os.path.abspath(config_file)
            fileConfig(config_file, dict(__file__=config_file,
                                         here=os.path.dirname(config_file))) 
开发者ID:galaxyproject,项目名称:pulsar,代码行数:16,代码来源:serve.py

示例4: ProvisionLoggers

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import fileConfig [as 别名]
def ProvisionLoggers(self):
        """Loads Log Handler & Config

        Returns:
            None: Simple loader, Nothing needed

        """
        if self._conf.get('Logging', 'ConfigurationFile'):
            if os.path.isfile(self._conf.get('Logging', 'ConfigurationFile')):
                config.fileConfig(self._conf.get('Logging', 'ConfigurationFile'))
                self._logger = logging.getLogger('GREASE')
            else:
                self.DefaultLogger()
        else:
            self.DefaultLogger() 
开发者ID:target,项目名称:grease,代码行数:17,代码来源:Logging.py

示例5: _use_config_file

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import fileConfig [as 别名]
def _use_config_file(cls, config_file):
        """Use parsed logging configuration."""
        try:
            config.fileConfig(cls._PARSER, disable_existing_loggers=False)
            LOG.info('Logging config file "%s" loaded successfully.',
                     config_file)
        except OSError:
            cls._catch_config_file_exception(config_file) 
开发者ID:kytos,项目名称:kytos,代码行数:10,代码来源:logs.py

示例6: setup_logging

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import fileConfig [as 别名]
def setup_logging():
    """Reads the Storj GUI logging configuration from logging.conf.
    If the file does not exist it will load a default configuration.

    Mac OS X (POSIX):
        ~/.storj-gui
    Unix (POSIX):
        ~/.storj-gui
    Win XP (not roaming):
        ``C:\Documents and Settings\<user>\Application Data\storj-gui``
    Win 7 (not roaming):
        ``C:\\Users\<user>\AppData\Local\storj-gui``
    """

    logging_conf = os.path.join(
        click.get_app_dir(APP_NAME, force_posix=True),
        'logging.conf')

    if not os.path.exists(logging_conf) or not os.path.isfile(logging_conf):
        load_default_logging()
        logging.getLogger(__name__).warning('%s logging configuration file does not exist', logging_conf)
        return

    try:
        config.fileConfig(logging_conf, disable_existing_loggers=False)
        logging.getLogger(__name__).info('%s configuration file was loaded.', logging_conf)

    except RuntimeError:
        load_default_logging()
        logging.getLogger(__name__).warning('failed to load configuration from %s', logging_conf)
        return

    logging.getLogger(__name__).info('using logging configuration from %s', logging_conf) 
开发者ID:lakewik,项目名称:EasyStorj,代码行数:35,代码来源:__init__.py


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