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


Python logging.conf方法代码示例

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


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

示例1: __call__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def __call__(self, argv=None):
        import json

        if argv is None:
            argv = sys.argv[1:]
        new_argv = []
        for a in argv:
            if not a.startswith('-D'):
                new_argv.append(a)
                continue
            conf, val = a[2:].split('=', 1)
            conf_parts = conf.split('.')
            conf_obj = options
            for g in conf_parts[:-1]:
                conf_obj = getattr(conf_obj, g)
            try:
                setattr(conf_obj, conf_parts[-1], json.loads(val))
            except:  # noqa: E722
                setattr(conf_obj, conf_parts[-1], val)

        return self._main(new_argv) 
开发者ID:mars-project,项目名称:mars,代码行数:23,代码来源:base_app.py

示例2: config_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def config_logging(self):
        import logging.config
        import mars
        log_conf = self.args.log_conf or 'logging.conf'

        conf_file_paths = [
            '', os.path.abspath('.'), os.path.dirname(os.path.dirname(mars.__file__))
        ]
        log_configured = False
        for path in conf_file_paths:
            conf_path = os.path.join(path, log_conf) if path else log_conf
            if os.path.exists(conf_path):
                logging.config.fileConfig(conf_path, disable_existing_loggers=False)
                log_configured = True
                break

        if not log_configured:
            log_level = self.args.log_level or self.args.level
            log_format = self.args.log_format or self.args.format
            level = getattr(logging, log_level.upper()) if log_level else logging.INFO
            logging.getLogger('mars').setLevel(level)
            logging.basicConfig(format=log_format) 
开发者ID:mars-project,项目名称:mars,代码行数:24,代码来源:base_app.py

示例3: load_conf_file

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def load_conf_file(conf_file):
    """Loads and parses conf file

        Loads and parses the module conf file

        Args:
            conf_file: string with the conf file name

        Returns:
            ConfigParser object with conf_file configs
    """

    if not os.path.isfile(conf_file):
        raise OneViewRedfishResourceNotFoundException(
            "File {} not found.".format(conf_file)
        )

    config = configparser.ConfigParser()
    config.optionxform = str
    try:
        config.read(conf_file)
    except Exception:
        raise

    return config 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:27,代码来源:config.py

示例4: load_configuration

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [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

示例5: auth_mode_is_conf

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def auth_mode_is_conf():
    return get_authentication_mode() == 'conf' 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:4,代码来源:config.py

示例6: configure_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def configure_logging(log_file_path):
    """Loads logging.conf file

        Loads logging.conf file to create the logger configuration.

        The logger configuration has two handlers, one of stream
        (show logs in the console) and other of file (save a log file)
        where you can choose one of it in [logger_root : handlers].
        In it you can choose the logger level as well.

        Level: Numeric value
        ---------------------
        CRITICAL: 50
        ERROR:    40
        WARNING:  30
        INFO:     20
        DEBUG:    10
        NOTSET:   00
        ---------------------

        How to use: import logging and logging.exception('message')

        Args:
            log_file_path: logging.conf path.

        Exception:
            Exception: if logging.conf file not found.
    """
    if os.path.isfile(log_file_path) is False:
        raise Exception("Config file {} not found".format(log_file_path))
    else:
        logging.config.fileConfig(log_file_path) 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:34,代码来源:config.py

示例7: config_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def config_logging():
    """
    Init the logging info
    """
    try:
        # First look at /etc/im/logging.conf file
        logging.config.fileConfig('/etc/im/logging.conf')
    except Exception as ex:
        print(ex)
        log_dir = os.path.dirname(Config.LOG_FILE)
        if not os.path.isdir(log_dir):
            os.makedirs(log_dir)

        fileh = logging.handlers.RotatingFileHandler(
            filename=Config.LOG_FILE, maxBytes=Config.LOG_FILE_MAX_SIZE, backupCount=3)
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        fileh.setFormatter(formatter)

        if Config.LOG_LEVEL == "DEBUG":
            log_level = logging.DEBUG
        elif Config.LOG_LEVEL == "INFO":
            log_level = logging.INFO
        elif Config.LOG_LEVEL in ["WARN", "WARNING"]:
            log_level = logging.WARN
        elif Config.LOG_LEVEL == "ERROR":
            log_level = logging.ERROR
        elif Config.LOG_LEVEL in ["FATAL", "CRITICAL"]:
            log_level = logging.FATAL
        else:
            log_level = logging.WARN

        logging.RootLogger.propagate = 0
        logging.root.setLevel(logging.ERROR)

        log = logging.getLogger('ConfManager')
        log.setLevel(log_level)
        log.propagate = 0
        log.addHandler(fileh)

        log = logging.getLogger('CloudConnector')
        log.setLevel(log_level)
        log.propagate = 0
        log.addHandler(fileh)

        log = logging.getLogger('InfrastructureManager')
        log.setLevel(log_level)
        log.propagate = 0
        log.addHandler(fileh)

    # Add the filter to add extra fields
    try:
        filt = ExtraInfoFilter()
        log = logging.getLogger('ConfManager')
        log.addFilter(filt)
        log = logging.getLogger('CloudConnector')
        log.addFilter(filt)
        log = logging.getLogger('InfrastructureManager')
        log.addFilter(filt)
    except Exception as ex:
        print(ex) 
开发者ID:grycap,项目名称:im,代码行数:62,代码来源:im_service.py

示例8: load_config

# 需要导入模块: import logging [as 别名]
# 或者: from logging import conf [as 别名]
def load_config(conf_file):
    """Loads redfish.conf file

        Loads and parsers the system conf file into config global var
        Loads json schemas into schemas_dict global var
        Established a connection with OneView and sets in as ov_conn
        global var

        Args:
            conf_file: string with the conf file name

        Returns:
            None

        Exception:
            HPOneViewException:
                - if fails to connect to oneview
    """

    config = load_conf_file(conf_file)
    globals()['config'] = config

    # Config file read set global vars
    # Setting ov_config
    # ov_config = dict(config.items('oneview_config'))
    # ov_config['credentials'] = dict(config.items('credentials'))
    # ov_config['api_version'] = API_VERSION
    # globals()['ov_config'] = ov_config

    util.load_event_service_info()

    # Load schemas | Store schemas
    try:
        for ip_oneview in get_oneview_multiple_ips():
            connection.check_oneview_availability(ip_oneview)

        registry_dict = load_registry(
            get_registry_path(),
            schemas.REGISTRY)
        globals()['registry_dict'] = registry_dict

        load_schemas(get_schemas_path())
    except Exception as e:
        raise OneViewRedfishException(
            'Failed to connect to OneView: {}'.format(e)
        ) 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:48,代码来源:config.py


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