我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用oslo_log.log.setup()。
def setup_log(): logging.register_options(CONF) conf_kwargs = dict(args=[], project=DOMAIN, version=VERSION) callback_config = parse_callback_config() if callback_config['ironic_config']: conf_kwargs['default_config_files'] = [ callback_config['ironic_config']] CONF(**conf_kwargs) if callback_config['use_journal']: CONF.set_override('use_journal', True) if callback_config['use_syslog']: CONF.set_override('use_syslog', True) if callback_config['ironic_log_file']: CONF.set_override("log_file", callback_config['ironic_log_file']) logging.setup(CONF, DOMAIN)
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 main(): core.initialize() logging.register_options(CONF) logging.setup(CONF, 'trio2o-db-manage') CONF.register_cli_opt(command_opt) version_info = pbr.version.VersionInfo('trio2o') try: CONF(sys.argv[1:], project='trio2o', prog='trio2o-db-manage', version=version_info.version_string()) except RuntimeError as e: sys.exit("ERROR: %s" % e) try: CONF.command.func() except Exception as e: sys.exit("ERROR: %s" % e)
def prepare_service(argv=None, config_files=None, share=False): conf = cfg.ConfigOpts() for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == "DEFAULT" else group) db_options.set_defaults(conf) if not share: defaults.set_cors_middleware_defaults() oslo_i18n.enable_lazy() log.register_options(conf) if argv is None: argv = sys.argv conf(argv[1:], project='panko', validate_default_values=True, version=version.version_info.version_string(), default_config_files=config_files) if not share: log.setup(conf, 'panko') # NOTE(liusheng): guru cannot run with service under apache daemon, so when # panko-api running with mod_wsgi, the argv is [], we don't start # guru. if argv: gmr.TextGuruMeditation.setup_autorun(version) return conf
def main(): register_keystoneauth_opts(CONF) CONF(sys.argv[1:], version='1.0.17', default_config_files=config.find_config_files()) logging.setup(CONF, 'join') transport = oslo_messaging.get_notification_transport(CONF) targets = [oslo_messaging.Target(topic=CONF.notifications_topic)] endpoints = [NotificationEndpoint()] server = oslo_messaging.get_notification_listener(transport, targets, endpoints, executor='threading') LOG.info("Starting") server.start() try: while True: time.sleep(1) except KeyboardInterrupt: LOG.info("Stopping, be patient") server.stop() server.wait()
def __init__(self): logging.register_options(CONF) DOMAIN = "s4t-lightning-rod" CONF(project='iotronic') logging.setup(CONF, DOMAIN) signal.signal(signal.SIGINT, self.stop_handler) LogoLR() global board board = Board() LOG.info('Info:') LOG.info(' - Logs: /var/log/s4t-lightning-rod.log') current_time = board.getTimestamp() LOG.info(" - Current time: " + current_time) self.w = WampManager(board.wamp_config) self.w.start()
def main(): try: config.parse_args(get_properly_ordered_parameters()) print_server_info() logging.setup(CONF, 'Qinling') # Initialize RPC configuration. rpc.get_transport() if cfg.CONF.server == ['all']: launch_any(LAUNCH_OPTIONS.keys()) else: if set(cfg.CONF.server) - set(LAUNCH_OPTIONS.keys()): raise Exception('Valid options are all or any combination of ' ', '.join(LAUNCH_OPTIONS.keys())) launch_any(set(cfg.CONF.server)) except RuntimeError as excp: sys.stderr.write("ERROR: %s\n" % excp) sys.exit(1)
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 main(): logging.register_options(CONF) logging.setup(CONF, 'bilean-manage') CONF.register_cli_opt(command_opt) try: default_config_files = cfg.find_config_files('bilean', 'bilean-engine') CONF(sys.argv[1:], project='bilean', prog='bilean-manage', version=version.version_info.version_string(), default_config_files=default_config_files) except RuntimeError as e: sys.exit("ERROR: %s" % e) try: CONF.command.func() except Exception as e: sys.exit("ERROR: %s" % e)
def main(): try: logging.register_options(cfg.CONF) cfg.CONF(project='bilean', prog='bilean-api', version=version.version_info.version_string()) logging.setup(cfg.CONF, 'bilean-api') messaging.setup() app = config.load_paste_app() port = cfg.CONF.bilean_api.bind_port host = cfg.CONF.bilean_api.bind_host LOG.info(_LI('Starting Bilean ReST API on %(host)s:%(port)s'), {'host': host, 'port': port}) server = wsgi.Server('bilean-api', cfg.CONF.bilean_api) server.start(app, default_port=port) systemd.notify_once() server.wait() except RuntimeError as ex: sys.exit("ERROR: %s" % six.text_type(ex))
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 prepare(CONF): """Prepare config options.""" global _initialized try: if _initialized is False: logging.register_options(CONF) _initialized = True # Adding config file possible_topdir = os.path.normpath( os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)) conf_file = os.path.join(possible_topdir, 'etc', DOMAIN + '.cfg') CONF([], project=DOMAIN, default_config_files=[conf_file] or None, validate_default_values=True) logging.setup(CONF, DOMAIN) except Exception as ex: LOG.error("Preparation failed! %s" % ex)
def prepare_log(service_name): log.register_options(CONF) CONF(default_config_files=['/etc/rock/rock.ini']) CONF.set_default('log_dir', '/var/log/rock') rock_mon_log_file = getattr(CONF, 'rock_mon_log_file', 'rock-mon.log') rock_engine_log_file = getattr(CONF, 'rock_engine_log_file', 'rock-engine.log') if service_name == 'rock-mon': CONF.set_override('log_file', override=rock_mon_log_file) elif service_name == 'rock-engine': CONF.set_override('log_file', override=rock_engine_log_file) else: raise exceptions.InvalidService(service_name=service_name) if not os.path.exists(CONF.log_dir): os.mkdir(CONF.log_dir) log.setup(CONF, service_name)
def openstack_base_setup(process_name): """General purpose entrypoint Sets up non-specific bits (the integration with OpenStack and its config, and so on). """ # Arguments, config files and options cfg.CONF(sys.argv[1:]) # General logging logging.setup(cfg.CONF, process_name) # Guru meditation support enabled gmr_opts.set_defaults(cfg.CONF) gmr.TextGuruMeditation.setup_autorun( version.version_info, service_name='vpp-agent')
def main(): # NOTE(jaosorior): This is needed in order for db-sync to also register the # keystonemiddleware options. Those options are used by clients that need a # keystone session in order to be able to register their actions. # This can be removed when mistral moves out of using keystonemiddleware in # favor of keystoneauth1. for group, opts in keystonemw_opts.list_auth_token_opts(): CONF.register_opts(opts, group=group) CONF.register_cli_opt(config.os_actions_mapping_path) config.parse_args() if len(CONF.config_file) == 0: print("Usage: sync_db --config-file <path-to-config-file>") return exit(1) logging.setup(CONF, 'Mistral') db_api.setup_db() action_manager.sync_db() workflows.sync_db()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "masakari") log = logging.getLogger(__name__) objects.register_all() launcher = service.process_launcher() started = 0 try: server = service.WSGIService("masakari_api", use_ssl=CONF.use_ssl) launcher.launch_service(server, workers=server.workers or 1) started += 1 except exception.PasteAppNotFound as ex: log.warning("%s. ``enabled_apis`` includes bad values. " "Fix to remove this warning.", six.text_type(ex)) if started == 0: log.error('No APIs were started. ' 'Check the enabled_apis config option.') sys.exit(1) launcher.wait()
def main(): CONF.register_cli_opts(scrubber.scrubber_cmd_cli_opts, group='scrubber') CONF.register_opts(scrubber.scrubber_cmd_opts, group='scrubber') try: config.parse_args() logging.setup(CONF, 'glare') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() app = scrubber.Scrubber() if CONF.scrubber.daemon: server = scrubber.Daemon(CONF.scrubber.wakeup_time) server.start(app) server.wait() else: app.run() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'glare') notification.set_defaults() if CONF.profiler.enabled: initializer.init_from_conf( conf=CONF, context={}, project="glare", service="api", host=CONF.bind_host ) server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glare-api'), default_port=9494) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): config.parse_args(sys.argv) logging.setup(CONF, 'nova') utils.monkey_patch() objects.register_all() gmr.TextGuruMeditation.setup_autorun(version) if not CONF.conductor.use_local: block_db_access() objects_base.NovaObject.indirection_api = \ conductor_rpcapi.ConductorAPI() else: LOG.warning(_LW('Conductor local mode is deprecated and will ' 'be removed in a subsequent release')) server = service.Service.create(binary='nova-compute', topic=CONF.compute_topic, db_allowed=CONF.conductor.use_local) service.serve(server) service.wait()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "nova") utils.monkey_patch() objects.register_all() gmr.TextGuruMeditation.setup_autorun(version) if not CONF.conductor.use_local: objects_base.NovaObject.indirection_api = \ conductor_rpcapi.ConductorAPI() should_use_ssl = 'metadata' in CONF.enabled_ssl_apis server = service.WSGIService('metadata', use_ssl=should_use_ssl) service.serve(server, workers=server.workers) service.wait()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "nova") utils.monkey_patch() objects.register_all() gmr.TextGuruMeditation.setup_autorun(version) if not CONF.conductor.use_local: block_db_access() objects_base.NovaObject.indirection_api = \ conductor_rpcapi.ConductorAPI() else: LOG.warning(_LW('Conductor local mode is deprecated and will ' 'be removed in a subsequent release')) server = service.Service.create(binary='nova-network', topic=CONF.network_topic, db_allowed=CONF.conductor.use_local) service.serve(server) service.wait()
def main(): try: opts.CONF(sys.argv[1:], project=opts.DOMAIN) logging.setup(opts.CONF, opts.DOMAIN) config = opts.CONF factory = core_factory.Factory(config) routes.instance_ctl = factory.get_instance_controller() routes.volume_ctl = factory.get_volume_controller() routes.volume_type_ctl = factory.get_volume_type_controller() routes.entity_ctl = factory.get_entity_controller() routes.app_ctl = factory.get_application_controller() routes.auth_adapter = auth_adapter.AuthenticationAdapter(config).get_authentication_adapter() LOG.info('Listening on %s:%d', config.api.bind_ip, config.api.bind_port) app.run(host=config.api.bind_ip, port=config.api.bind_port) except Exception as e: LOG.exception(e) sys.exit(100)
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 v2_playbook_on_task_start(self, task, is_conditional): # NOTE(pas-ha) I do not know (yet) how to obtain a ref to host # until first task is processed node = self.node or "Node" name = task.get_name() if name == 'setup': self.log.debug("Processing task %(name)s.", dict(name=name)) else: self.log.debug("Processing task %(name)s on node %(node)s.", dict(name=name, node=node))
def v2_runner_on_ok(self, result): msg_dict = self.runner_msg_dict(result) if msg_dict['name'] == 'setup': self.log.info("Ansible task 'setup' complete on node %(node)s", msg_dict) else: self.log.info("Ansible task %(name)s complete on node %(node)s: " "%(res)s", msg_dict)
def main(): logging.register_options(CONF) CONF(sys.argv[1:], project='craton-api', default_config_files=[]) logging.setup(CONF, 'craton-api') app = api.load_app() host, port = cfg.CONF.api.host, cfg.CONF.api.port srv = simple_server.make_server(host, port, app) LOG.info("Starting API server in PID: %s" % os.getpid()) srv.serve_forever()
def setup_logging(): logging.setup(CONF, 'vdibroker')
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, host): signal.signal(signal.SIGINT, self.stop_handler) logging.register_options(CONF) CONF(project='iotronic') logging.setup(CONF, "iotronic-wamp-agent") # to be removed asap self.host = host self.dbapi = dbapi.get_instance() try: wpa = self.dbapi.register_wampagent( {'hostname': self.host, 'wsurl': CONF.wamp.wamp_transport_url}) except exception.WampAgentAlreadyRegistered: LOG.warn(_LW("A wampagent with hostname %(hostname)s " "was previously registered. Updating registration"), {'hostname': self.host}) wpa = self.dbapi.register_wampagent( {'hostname': self.host, 'wsurl': CONF.wamp.wamp_transport_url}, update_existing=True) self.wampagent = wpa self.wampagent.ragent = CONF.wamp.register_agent self.wampagent.save() global AGENT_HOST AGENT_HOST = self.host self.r = RPCServer() self.w = WampManager() self.r.start() self.w.start()
def _setup_logging(): """Sets up the logging options for a log with supplied name.""" product_name = "trio2o" logging.setup(cfg.CONF, product_name) LOG.info(_LI("Logging enabled!")) LOG.info(_LI("%(prog)s version %(version)s"), {'prog': sys.argv[0], 'version': version.version_info}) LOG.debug("command line: %s", " ".join(sys.argv))
def main(): """Parse options and call the appropriate class/method.""" CONF.register_cli_opt(category_opt) script_name = sys.argv[0] if len(sys.argv) < 2: print(_("\nOpenStack meteos version: %(version)s\n") % {'version': version.version_string()}) print(script_name + " category action [<args>]") print(_("Available categories:")) for category in CATEGORIES: print("\t%s" % category) sys.exit(2) try: log.register_options(CONF) CONF(sys.argv[1:], project='meteos', version=version.version_string()) log.setup(CONF, "meteos") except cfg.ConfigFilesNotFoundError: cfgfile = CONF.config_file[-1] if CONF.config_file else None if cfgfile and not os.access(cfgfile, os.R_OK): st = os.stat(cfgfile) print(_("Could not read %s. Re-running with sudo") % cfgfile) try: os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv) except Exception: print(_('sudo failed, continuing as if nothing happened')) print(_('Please re-run meteos-manage as root.')) sys.exit(2) fn = CONF.category.action_fn fn_args = fetch_func_args(fn) fn(*fn_args)
def main(): log.register_options(CONF) CONF(sys.argv[1:], project='meteos', version=version.version_string()) log.setup(CONF, "meteos") utils.monkey_patch() launcher = service.process_launcher() server = service.WSGIService('osapi_learning') launcher.launch_service(server, workers=server.workers or 1) launcher.wait()
def prepare_service(argv=()): cfg.CONF(argv[1:]) logging.setup(cfg.CONF, 'shim')
def prepare_service(argv=()): cfg.CONF(argv[1:], project='gluon') logging.setup(cfg.CONF, 'gluon')
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 main(): # rcrit: work around "PKCS #11 module returned CKR_DEVICE_ERROR" os.environ['NSS_STRICT_NOFORK'] = 'DISABLED' keystone_client.register_keystoneauth_opts(CONF) CONF(sys.argv[1:], version='1.0.17', default_config_files=config.find_config_files()) log.setup(CONF, 'join') launcher = process_launcher() server = WSGIService('join') launcher.launch_service(server, workers=server.workers) launcher.wait()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "masakarimonitors") utils.monkey_patch() server = service.Service.create(binary='masakarimonitors-hostmonitor') service.serve(server) service.wait()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "masakarimonitors") utils.monkey_patch() server = service.Service.create(binary='masakarimonitors-processmonitor') service.serve(server) service.wait()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "masakarimonitors") utils.monkey_patch() server = service.Service.create(binary='masakarimonitors-instancemonitor') service.serve(server) service.wait()
def prepare_service(argv=None): if argv is None: argv = [] log.register_options(CONF) config.parse_args(argv) config.set_config_defaults() log.setup(CONF, 'zun') # TODO(yuanying): Uncomment after objects are implemented # objects.register_all()
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 setup_logging(): logging.setup(CONF, 'coriolis')
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 __init__(self): if not (os.path.exists(const.CONFIG_PATH)): set_default_for_default_log_levels() logging.setup(CONF, 'armada') self.logger = logging.getLogger(__name__)
def init_application(): config.init(sys.argv[1:]) logging.setup(config.CONF, 'fuxi') controllers.init_app_conf() return app
def start(): config.init(sys.argv[1:]) logging.setup(config.CONF, 'fuxi') controllers.init_app_conf() port = config.CONF.fuxi_port app.run("0.0.0.0", port, debug=config.CONF.debug, threaded=config.CONF.threaded)
def configure_app(): config.init(sys.argv[1:]) log.setup(config.CONF, 'kuryr') controllers.neutron_client() controllers.check_for_neutron_ext_support() controllers.check_for_neutron_tag_support( controllers.TAG_NEUTRON_EXTENSION) controllers.check_for_neutron_tag_support( controllers.TAG_EXT_NEUTRON_EXTENSION) controllers.load_default_subnet_pools() controllers.load_port_driver()
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