Python oslo_log.log.set_defaults() Examples

The following are 30 code examples of oslo_log.log.set_defaults(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module oslo_log.log , or try the search function .
Example #1
Source File: config.py    From qinling with Apache License 2.0 6 votes vote down vote up
def set_cors_middleware_defaults():
    """Update default configuration options for oslo.middleware."""
    cors.set_defaults(
        allow_headers=['X-Auth-Token',
                       'X-Identity-Status',
                       'X-Roles',
                       'X-Service-Catalog',
                       'X-User-Id',
                       'X-Tenant-Id',
                       'X-Project-Id',
                       'X-User-Name',
                       'X-Project-Name'],
        allow_methods=['GET',
                       'PUT',
                       'POST',
                       'DELETE',
                       'PATCH'],
        expose_headers=['X-Auth-Token',
                        'X-Subject-Token',
                        'X-Service-Token',
                        'X-Project-Id',
                        'X-User-Name',
                        'X-Project-Name']
    ) 
Example #2
Source File: config.py    From masakari with Apache License 2.0 6 votes vote down vote up
def parse_args(argv, default_config_files=None, configure_db=True,
               init_rpc=True):
    log.register_options(CONF)
    # We use the oslo.log default log levels which includes suds=INFO
    # and add only the extra levels that Masakari needs
    log.set_defaults(default_log_levels=log.get_default_log_levels())
    rpc.set_defaults(control_exchange='masakari')
    config.set_middleware_defaults()

    CONF(argv[1:],
         project='masakari',
         version=version.version_string(),
         default_config_files=default_config_files)

    if init_rpc:
        rpc.init(CONF)

    if configure_db:
        sqlalchemy_api.configure(CONF) 
Example #3
Source File: conductor.py    From senlin with Apache License 2.0 6 votes vote down vote up
def main():
    config.parse_args(sys.argv, 'senlin-conductor')
    logging.setup(CONF, 'senlin-conductor')
    logging.set_defaults()
    gmr.TextGuruMeditation.setup_autorun(version)
    objects.register_all()
    messaging.setup()

    from senlin.conductor import service as conductor

    profiler.setup('senlin-conductor', CONF.host)
    srv = conductor.ConductorService(CONF.host, consts.CONDUCTOR_TOPIC)
    launcher = service.launch(CONF, srv,
                              workers=CONF.conductor.workers,
                              restart_method='mutate')
    # the following periodic tasks are intended serve as HA checking
    # srv.create_periodic_tasks()
    launcher.wait() 
Example #4
Source File: engine.py    From senlin with Apache License 2.0 6 votes vote down vote up
def main():
    config.parse_args(sys.argv, 'senlin-engine')
    logging.setup(CONF, 'senlin-engine')
    logging.set_defaults()
    gmr.TextGuruMeditation.setup_autorun(version)
    objects.register_all()
    messaging.setup()

    from senlin.engine import service as engine

    profiler.setup('senlin-engine', CONF.host)
    srv = engine.EngineService(CONF.host,
                               consts.ENGINE_TOPIC)
    launcher = service.launch(CONF, srv,
                              workers=CONF.engine.workers,
                              restart_method='mutate')
    launcher.wait() 
Example #5
Source File: health_manager.py    From senlin with Apache License 2.0 6 votes vote down vote up
def main():
    config.parse_args(sys.argv, 'senlin-health-manager')
    logging.setup(CONF, 'senlin-health-manager')
    logging.set_defaults()
    gmr.TextGuruMeditation.setup_autorun(version)
    objects.register_all()
    messaging.setup()

    from senlin.health_manager import service as health_manager

    profiler.setup('senlin-health-manager', CONF.host)
    srv = health_manager.HealthManagerService(CONF.host,
                                              consts.HEALTH_MANAGER_TOPIC)
    launcher = service.launch(CONF, srv,
                              workers=CONF.health_manager.workers,
                              restart_method='mutate')
    launcher.wait() 
Example #6
Source File: opts.py    From ironic-inspector with Apache License 2.0 5 votes vote down vote up
def set_config_defaults():
    """Return a list of oslo.config options available in Inspector code."""
    log.set_defaults(default_log_levels=['sqlalchemy=WARNING',
                                         'iso8601=WARNING',
                                         'requests=WARNING',
                                         'urllib3.connectionpool=WARNING',
                                         'keystonemiddleware=WARNING',
                                         'keystoneauth=WARNING',
                                         'ironicclient=WARNING',
                                         'amqp=WARNING',
                                         'amqplib=WARNING',
                                         # This comes in two flavors
                                         'oslo.messaging=WARNING',
                                         'oslo_messaging=WARNING'])
    set_cors_middleware_defaults() 
Example #7
Source File: service.py    From cyborg with Apache License 2.0 5 votes vote down vote up
def prepare_service(argv=None):
    log.register_options(CONF)
    log.set_defaults(default_log_levels=CONF.default_log_levels)

    argv = argv or []
    config.parse_args(argv)

    log.setup(CONF, 'cyborg')
    objects.register_all() 
Example #8
Source File: config.py    From monasca-log-api with Apache License 2.0 5 votes vote down vote up
def parse_args(argv=None):
    global _CONF_LOADED
    if _CONF_LOADED:
        LOG.debug('Configuration has been already loaded')
        return

    log.set_defaults()
    log.register_options(CONF)

    argv = (argv if argv is not None else sys.argv[1:])
    args = ([] if _is_running_under_gunicorn() else argv or [])

    CONF(args=args,
         prog=sys.argv[1:],
         project='monasca',
         version=version.version_str,
         default_config_files=get_config_files(),
         description='RESTful API to collect log files')

    log.setup(CONF,
              product_name='monasca-log-api',
              version=version.version_str)

    conf.register_opts()
    policy_opts.set_defaults(CONF)

    _CONF_LOADED = True 
Example #9
Source File: config.py    From monasca-notification with Apache License 2.0 5 votes vote down vote up
def parse_args(argv):
    """Sets up configuration of monasca-notification."""

    global _CONF_LOADED
    if _CONF_LOADED:
        LOG.debug('Configuration has been already loaded')
        return

    conf.register_opts(CONF)
    log.register_options(CONF)

    default_log_levels = (log.get_default_log_levels())
    log.set_defaults(default_log_levels=default_log_levels)

    CONF(args=argv,
         project='monasca',
         prog=sys.argv[1:],
         version=version.version_string,
         default_config_files=_get_config_files(),
         description='''
         monasca-notification is an engine responsible for
         transforming alarm transitions into proper notifications
         ''')

    conf.register_enabled_plugin_opts(CONF)

    log.setup(CONF,
              product_name='monasca-notification',
              version=version.version_string)

    _CONF_LOADED = True 
Example #10
Source File: opts.py    From ironic-inspector with Apache License 2.0 5 votes vote down vote up
def set_cors_middleware_defaults():
    """Update default configuration options for oslo.middleware."""
    cors.set_defaults(
        allow_headers=['X-Auth-Token',
                       MIN_VERSION_HEADER,
                       MAX_VERSION_HEADER,
                       VERSION_HEADER],
        allow_methods=['GET', 'POST', 'PUT', 'HEAD',
                       'PATCH', 'DELETE', 'OPTIONS']
    ) 
Example #11
Source File: service.py    From aodh with Apache License 2.0 5 votes vote down vote up
def prepare_service(argv=None, config_files=None):
    conf = cfg.ConfigOpts()
    oslo_i18n.enable_lazy()
    log.register_options(conf)
    log_levels = (
        conf.default_log_levels +
        [
            'futurist=INFO',
            'keystoneclient=INFO',
            'oslo_db.sqlalchemy=WARN',
            'cotyledon=INFO'
        ]
    )
    log.set_defaults(default_log_levels=log_levels)
    defaults.set_cors_middleware_defaults()
    db_options.set_defaults(conf)
    if profiler_opts:
        profiler_opts.set_defaults(conf)
    policy_opts.set_defaults(conf, policy_file=os.path.abspath(
        os.path.join(os.path.dirname(__file__), "api", "policy.json")))
    from aodh import opts
    # Register our own Aodh options
    for group, options in opts.list_opts():
        conf.register_opts(list(options),
                           group=None if group == "DEFAULT" else group)
    keystone_client.register_keystoneauth_opts(conf)

    conf(argv, project='aodh', validate_default_values=True,
         default_config_files=config_files)

    ka_loading.load_auth_from_conf_options(conf, "service_credentials")
    log.setup(conf, 'aodh')
    profiler.setup(conf)
    messaging.setup()
    return conf 
Example #12
Source File: config.py    From qinling with Apache License 2.0 5 votes vote down vote up
def parse_args(args=None, usage=None, default_config_files=None):
    CLI_OPTS = [launch_opt]
    CONF.register_cli_opts(CLI_OPTS)

    for group, options in list_opts():
        CONF.register_opts(list(options), group)

    _DEFAULT_LOG_LEVELS = [
        'eventlet.wsgi.server=WARN',
        'oslo_service.periodic_task=INFO',
        'oslo_service.loopingcall=INFO',
        'oslo_db=WARN',
        'oslo_concurrency.lockutils=WARN',
        'kubernetes.client.rest=%s' % CONF.kubernetes.log_devel,
        'keystoneclient=INFO',
        'requests.packages.urllib3.connectionpool=CRITICAL',
        'urllib3.connectionpool=CRITICAL',
        'cotyledon=INFO',
        'futurist.periodics=WARN'
    ]
    default_log_levels = log.get_default_log_levels()
    default_log_levels.extend(_DEFAULT_LOG_LEVELS)
    log.set_defaults(default_log_levels=default_log_levels)
    log.register_options(CONF)

    CONF(
        args=args,
        project='qinling',
        version=version,
        usage=usage,
        default_config_files=default_config_files
    ) 
Example #13
Source File: config.py    From monasca-api with Apache License 2.0 5 votes vote down vote up
def parse_args(argv=None):
    """Loads application configuration.

    Loads entire application configuration just once.

    """
    global _CONF_LOADED
    if _CONF_LOADED:
        LOG.debug('Configuration has been already loaded')
        return

    log.set_defaults()
    log.register_options(CONF)

    argv = (argv if argv is not None else sys.argv[1:])
    args = ([] if _is_running_under_gunicorn() else argv or [])

    CONF(args=args,
         prog=sys.argv[1:],
         project='monasca',
         version=version.version_str,
         default_config_files=get_config_files(),
         description='RESTful API for alarming in the cloud')

    log.setup(CONF,
              product_name='monasca-api',
              version=version.version_str)
    conf.register_opts()
    policy_opts.set_defaults(CONF)

    _CONF_LOADED = True 
Example #14
Source File: bifrost_inventory.py    From bifrost with Apache License 2.0 5 votes vote down vote up
def _parse_config():
    config = cfg.ConfigOpts()
    log.register_options(config)
    config.register_cli_opts(opts)
    config(prog='bifrost_inventory.py')
    log.set_defaults()
    log.setup(config, "bifrost_inventory.py")
    return config 
Example #15
Source File: inventory.py    From bifrost with Apache License 2.0 5 votes vote down vote up
def _parse_config():
    config = cfg.ConfigOpts()
    log.register_options(config)
    config.register_cli_opts(opts)
    config(prog='bifrost_inventory.py')
    log.set_defaults()
    log.setup(config, "bifrost_inventory.py")
    return config 
Example #16
Source File: service.py    From cloudkitty with Apache License 2.0 5 votes vote down vote up
def prepare_service(argv=None, config_files=None):
    oslo_i18n.enable_lazy()
    log.register_options(cfg.CONF)
    log.set_defaults()
    defaults.set_cors_middleware_defaults()

    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='cloudkitty', validate_default_values=True,
             version=version.version_info.version_string(),
             default_config_files=config_files)

    log.setup(cfg.CONF, 'cloudkitty')
    messaging.setup() 
Example #17
Source File: test_log.py    From oslo.log with Apache License 2.0 5 votes vote down vote up
def test_tempest_set_log_file(self):
        log_file = 'foo.log'
        log.tempest_set_log_file(log_file)
        self.addCleanup(log.tempest_set_log_file, None)
        log.set_defaults()
        self.conf([])
        self.assertEqual(log_file, self.conf.log_file) 
Example #18
Source File: usage.py    From oslo.log with Apache License 2.0 5 votes vote down vote up
def prepare():
    """Prepare Oslo Logging (2 or 3 steps)

    Use of Oslo Logging involves the following:

    * logging.register_options
    * logging.set_defaults (optional)
    * logging.setup
    """

    # Required step to register common, logging and generic configuration
    # variables
    logging.register_options(CONF)

    # Optional step to set new defaults if necessary for
    # * logging_context_format_string
    # * default_log_levels
    #
    # These variables default to respectively:
    #
    #  import oslo_log
    #  oslo_log._options.DEFAULT_LOG_LEVELS
    #  oslo_log._options.log_opts[0].default
    #

    extra_log_level_defaults = [
        'dogpile=INFO',
        'routes=INFO'
        ]

    logging.set_defaults(
        default_log_levels=logging.get_default_log_levels() +
        extra_log_level_defaults)

    # Required setup based on configuration and domain
    logging.setup(CONF, DOMAIN) 
Example #19
Source File: usage_context.py    From oslo.log with Apache License 2.0 5 votes vote down vote up
def prepare():
    """Prepare Oslo Logging (2 or 3 steps)

    Use of Oslo Logging involves the following:

    * logging.register_options
    * logging.set_defaults (optional)
    * logging.setup
    """

    # Required step to register common, logging and generic configuration
    # variables
    logging.register_options(CONF)

    # Optional step to set new defaults if necessary for
    # * logging_context_format_string
    # * default_log_levels
    #
    # These variables default to respectively:
    #
    #  import oslo_log
    #  oslo_log._options.DEFAULT_LOG_LEVELS
    #  oslo_log._options.log_opts[0].default
    #

    extra_log_level_defaults = [
        'dogpile=INFO',
        'routes=INFO'
        ]

    logging.set_defaults(
        default_log_levels=logging.get_default_log_levels() +
        extra_log_level_defaults)

    # Required setup based on configuration and domain
    logging.setup(CONF, DOMAIN) 
Example #20
Source File: test_log.py    From oslo.log with Apache License 2.0 5 votes vote down vote up
def test_log_file_defaults_to_none(self):
        log.set_defaults()
        self.conf([])
        self.assertIsNone(self.conf.log_file) 
Example #21
Source File: server.py    From armada with Apache License 2.0 5 votes vote down vote up
def create(enable_middleware=CONF.middleware):
    """Entry point for initializing Armada server.

    :param enable_middleware: Whether to enable middleware.
    :type enable_middleware: bool
    """

    if enable_middleware:
        api = falcon.API(
            request_type=ArmadaRequest,
            middleware=[
                AuthMiddleware(),
                ContextMiddleware(),
                LoggingMiddleware(),
            ])
    else:
        api = falcon.API(request_type=ArmadaRequest)

    logging.set_defaults(default_log_levels=CONF.default_log_levels)
    logging.setup(CONF, 'armada')

    # Configure API routing
    url_routes_v1 = (
        ('health', Health()),
        ('apply', Apply()),
        ('releases', Release()),
        ('status', Status()),
        ('tests', TestReleasesManifestController()),
        ('test/{release}', TestReleasesReleaseNameController()),
        ('validatedesign', Validate()),
    )

    for route, service in url_routes_v1:
        api.add_route("/api/v1.0/{}".format(route), service)
    api.add_route('/versions', Versions())

    # Initialize policy config options.
    policy.Enforcer(CONF)

    return api 
Example #22
Source File: config.py    From kuryr-kubernetes with Apache License 2.0 5 votes vote down vote up
def setup_logging():

    logging.setup(CONF, 'kuryr-kubernetes')
    logging.set_defaults(default_log_levels=logging.get_default_log_levels())
    version_k8s = version.version_info.version_string()
    LOG.info("Logging enabled!")
    LOG.info("%(prog)s version %(version)s",
             {'prog': sys.argv[0], 'version': version_k8s}) 
Example #23
Source File: options.py    From castellan with Apache License 2.0 5 votes vote down vote up
def enable_logging(conf=None, app_name='castellan'):
    conf = conf or cfg.CONF

    log.register_options(conf)
    log.set_defaults(_DEFAULT_LOGGING_CONTEXT_FORMAT,
                     _DEFAULT_LOG_LEVELS)

    log.setup(conf, app_name) 
Example #24
Source File: cli.py    From octavia with Apache License 2.0 5 votes vote down vote up
def add_command_parsers(subparsers):
    for name in ['current', 'history', 'branches']:
        parser = add_alembic_subparser(subparsers, name)
        parser.set_defaults(func=do_alembic_command)

    help_text = (getattr(alembic_cmd, 'branches').__doc__ +
                 ' and validate head file')
    parser = subparsers.add_parser('check_migration', help=help_text)
    parser.set_defaults(func=do_check_migration)

    parser = add_alembic_subparser(subparsers, 'upgrade')
    parser.add_argument('--delta', type=int)
    parser.add_argument('--sql', action='store_true')
    parser.add_argument('revision', nargs='?')
    parser.set_defaults(func=do_upgrade)

    parser = subparsers.add_parser(
        "upgrade_persistence",
        help="Run migrations for persistence backend")
    parser.set_defaults(func=do_persistence_upgrade)

    parser = subparsers.add_parser('downgrade', help="(No longer supported)")
    parser.add_argument('None', nargs='?', help="Downgrade not supported")
    parser.set_defaults(func=no_downgrade)

    parser = add_alembic_subparser(subparsers, 'stamp')
    parser.add_argument('--sql', action='store_true')
    parser.add_argument('revision')
    parser.set_defaults(func=do_stamp)

    parser = add_alembic_subparser(subparsers, 'revision')
    parser.add_argument('-m', '--message')
    parser.add_argument('--autogenerate', action='store_true')
    parser.add_argument('--sql', action='store_true')
    parser.set_defaults(func=do_revision) 
Example #25
Source File: config.py    From octavia with Apache License 2.0 5 votes vote down vote up
def setup_logging(conf):
    """Sets up the logging options for a log with supplied name.

    :param conf: a cfg.ConfOpts object
    """
    logging.set_defaults(default_log_levels=logging.get_default_log_levels() +
                         EXTRA_LOG_LEVEL_DEFAULTS)
    product_name = "octavia"
    logging.setup(conf, product_name)
    LOG.info("Logging enabled!")
    LOG.info("%(prog)s version %(version)s",
             {'prog': sys.argv[0],
              'version': version.version_info.release_string()})
    LOG.debug("command line: %s", " ".join(sys.argv)) 
Example #26
Source File: config.py    From freezer-api with Apache License 2.0 5 votes vote down vote up
def setup_logging():
    _DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'boto=WARN',
                           'stevedore=WARN', 'oslo_log=INFO',
                           'iso8601=WARN', 'elasticsearch=WARN',
                           'requests.packages.urllib3.connectionpool=WARN',
                           'urllib3.connectionpool=WARN', 'websocket=WARN',
                           'keystonemiddleware=WARN', 'routes.middleware=WARN']
    _DEFAULT_LOGGING_CONTEXT_FORMAT = ('%(asctime)s.%(msecs)03d %(process)d '
                                       '%(levelname)s %(name)s [%(request_id)s'
                                       ' %(user_identity)s] %(instance)s '
                                       '%(message)s')
    log.set_defaults(_DEFAULT_LOGGING_CONTEXT_FORMAT, _DEFAULT_LOG_LEVELS)
    log.setup(CONF, 'freezer-api', version=FREEZER_API_VERSION) 
Example #27
Source File: __init__.py    From armada with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        self.logger = LOG
        logging.set_defaults(default_log_levels=CONF.default_log_levels)
        logging.setup(CONF, 'armada') 
Example #28
Source File: __init__.py    From armada with Apache License 2.0 5 votes vote down vote up
def set_default_for_default_log_levels():
    """Set the default for the default_log_levels option for Armada.
    Armada uses some packages that other OpenStack services don't use that do
    logging. This will set the default_log_levels default level for those
    packages.
    This function needs to be called before CONF().
    """

    extra_log_level_defaults = ['kubernetes.client.rest=INFO']

    log.set_defaults(
        default_log_levels=log.get_default_log_levels()
        + extra_log_level_defaults, ) 
Example #29
Source File: config.py    From ec2-api with Apache License 2.0 5 votes vote down vote up
def parse_args(argv, default_config_files=None):
    log.set_defaults(_DEFAULT_LOGGING_CONTEXT_FORMAT, _DEFAULT_LOG_LEVELS)
    log.register_options(CONF)
    options.set_defaults(CONF, connection=_DEFAULT_SQL_CONNECTION)

    cfg.CONF(argv[1:],
             project='ec2api',
             version=version.version_info.version_string(),
             default_config_files=default_config_files) 
Example #30
Source File: __init__.py    From armada with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        self.logger = LOG
        logging.register_options(CONF)
        logging.set_defaults(default_log_levels=CONF.default_log_levels)
        logging.setup(CONF, 'armada')