我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用oslo_log.log.set_defaults()。
def prepare_service(argv=[]): log.register_options(cfg.CONF) log.set_defaults(default_log_levels=['amqp=WARN', 'amqplib=WARN', 'qpid.messagregister_optionsing=INFO', 'oslo.messaging=INFO', 'sqlalchemy=WARN', 'keystoneclient=INFO', 'stevedore=INFO', 'eventlet.wsgi.server=WARN', 'iso8601=WARN', 'paramiko=WARN', 'requests=WARN', 'neutronclient=WARN', 'glanceclient=WARN', 'iotronic.openstack.common=WARN', 'urllib3.connectionpool=WARN', ]) config.parse_args(argv) log.setup(cfg.CONF, 'iotronic')
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.register_options(CONF) log.set_defaults( default_log_levels=log.get_default_log_levels() + extra_log_level_defaults)
def setup_logging(): """Set some oslo log defaults.""" _DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'boto=WARN', 'qpid=WARN', 'stevedore=WARN', 'oslo_log=INFO', 'iso8601=WARN', 'requests.packages.urllib3.connectionpool=WARN', 'urllib3.connectionpool=WARN', 'websocket=WARN', 'keystonemiddleware=WARN', 'freezer-dr=INFO'] _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-dr', version=FREEZER_DR_VERSION)
def init_config_and_logging(opts): conf = cfg.CONF conf.register_cli_opts(opts) conf.register_opts(opts) logging.register_options(conf) logging.set_defaults() try: conf(project='performa') validate_required_opts(conf, opts) except cfg.RequiredOptError as e: print('Error: %s' % e) conf.print_usage() exit(1) logging.setup(conf, 'performa') LOG.info('Logging enabled') conf.log_opt_values(LOG, std_logging.DEBUG)
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)
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 Nova needs log.set_defaults(default_log_levels=log.get_default_log_levels() + _EXTRA_DEFAULT_LOG_LEVELS) options.set_defaults(CONF, connection=_DEFAULT_SQL_CONNECTION, sqlite_db='nova.sqlite') rpc.set_defaults(control_exchange='nova') cache.configure(CONF) config.set_middleware_defaults() CONF(argv[1:], project='nova', version=version.version_string(), default_config_files=default_config_files) if init_rpc: rpc.init(CONF) if configure_db: sqlalchemy_api.configure(CONF)
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})
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()
def __init__(self): if osloConfig: logging.register_options(cfg.CONF) logging.set_defaults() cfg.CONF(args=[], project="broadview_collector", default_config_files=["/etc/broadviewcollector.conf"]) logging.setup(cfg.CONF, 'broadview_collector') self._publishers = [] self._handlers = []
def parse_args(argv, default_config_files=None): 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()) CONF(argv[1:], project='masakarimonitors', version=version.version_string(), default_config_files=default_config_files)
def setup_logging(conf): # Add additional dependent libraries that have unhelp bug levels extra_log_level_defaults = [] logging.set_defaults(default_log_levels=logging.get_default_log_levels() + extra_log_level_defaults) logging.setup(conf, 'deckhand') py_logging.captureWarnings(True)
def __init__(self): self.logger = LOG logging.register_options(CONF) logging.set_defaults(default_log_levels=CONF.default_log_levels) logging.setup(CONF, 'armada')
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', ] 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 )
def parse_args(): """Parse configuration arguments. Note: This method ensures that configuration will be loaded only once within single python interpreter. """ global _CONF_LOADED if _CONF_LOADED: LOG.debug('Configuration has been already loaded') return log.set_defaults() log.register_options(CONF) CONF(args=[], prog='events-api', project='monasca', version=version.version_str, description='RESTful API to collect events from cloud') log.setup(CONF, product_name='monasca-events-api', version=version.version_str) conf.register_opts(CONF) policy_opts.set_defaults(CONF) _CONF_LOADED = True
def setup_logging(): """Sets up the logging options.""" # We use the oslo.log default log levels but set the log level for # zhmcclient library to warning logging.set_defaults(default_log_levels=logging.get_default_log_levels() + ["zhmcclient=WARNING"]) logging.setup(CONF, 'neutron') LOG.info("Logging enabled!") LOG.info("%(prog)s", {'prog': sys.argv[0]}) LOG.debug("command line: %s", " ".join(sys.argv))
def main(): logging.register_options(cfg.CONF) cfg.CONF(project='bilean', prog='bilean-engine') logging.setup(cfg.CONF, 'bilean-engine') logging.set_defaults() messaging.setup() from bilean.engine import service as engine srv = engine.EngineService(cfg.CONF.host, consts.ENGINE_TOPIC) launcher = service.launch(cfg.CONF, srv, workers=cfg.CONF.num_engine_workers) launcher.wait()
def main(): logging.register_options(cfg.CONF) cfg.CONF(project='bilean', prog='bilean-notification') logging.setup(cfg.CONF, 'bilean-notification') logging.set_defaults() messaging.setup() from bilean.notification import notification srv = notification.NotificationService() launcher = service.launch(cfg.CONF, srv) launcher.wait()
def main(): logging.register_options(cfg.CONF) cfg.CONF(project='bilean', prog='bilean-scheduler') logging.setup(cfg.CONF, 'bilean-scheduler') logging.set_defaults() messaging.setup() from bilean.scheduler import service as scheduler srv = scheduler.SchedulerService(cfg.CONF.host, consts.SCHEDULER_TOPIC) launcher = service.launch(cfg.CONF, srv) launcher.wait()
def prepare_service(argv=None): argv = [] if argv is None else argv log.register_options(CONF) log.set_defaults(default_log_levels=CONF.default_log_levels + [ 'eventlet.wsgi.server=INFO', 'neutronclient=WARNING']) config.parse_args(argv) log.setup(CONF, 'mogan') objects.register_all()
def add_command_parsers(subparsers): parser = subparsers.add_parser('version') parser = subparsers.add_parser('bash-completion') parser.add_argument('query_category', nargs='?') for category in CATEGORIES: command_object = CATEGORIES[category]() desc = getattr(command_object, 'description', None) parser = subparsers.add_parser(category, description=desc) parser.set_defaults(command_object=command_object) category_subparsers = parser.add_subparsers(dest='action') for (action, action_fn) in methods_of(command_object): parser = category_subparsers.add_parser(action, description=desc) action_kwargs = [] for args, kwargs in getattr(action_fn, 'args', []): # FIXME(markmc): hack to assume dest is the arg name without # the leading hyphens if no dest is supplied kwargs.setdefault('dest', args[0][2:]) if kwargs['dest'].startswith('action_kwarg_'): action_kwargs.append( kwargs['dest'][len('action_kwarg_'):]) else: action_kwargs.append(kwargs['dest']) kwargs['dest'] = 'action_kwarg_' + kwargs['dest'] parser.add_argument(*args, **kwargs) parser.set_defaults(action_fn=action_fn) parser.set_defaults(action_kwargs=action_kwargs) parser.add_argument('action_args', nargs='*', help=argparse.SUPPRESS)
def main(ctx, debug, api, url, token): """ Multi Helm Chart Deployment Manager Common actions from this point include: \b $ armada apply $ armada test $ armada tiller $ armada validate Environment: \b $TOKEN set auth token $HOST set armada service host endpoint This tool will communicate with deployed Tiller in your Kubernetes cluster. """ if not ctx.obj: ctx.obj = {} if api: if not url or not token: raise click.ClickException( 'When api option is enable user needs to pass url') else: ctx.obj['api'] = api parsed_url = urlparse(url) ctx.obj['CLIENT'] = ArmadaClient( ArmadaSession( host=parsed_url.netloc, scheme=parsed_url.scheme, token=token) ) log.register_options(CONF) if debug: CONF.debug = debug log.set_defaults(default_log_levels=CONF.default_log_levels) log.setup(CONF, 'armada')