本文整理匯總了Python中oslo_log.log.DEBUG屬性的典型用法代碼示例。如果您正苦於以下問題:Python log.DEBUG屬性的具體用法?Python log.DEBUG怎麽用?Python log.DEBUG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類oslo_log.log
的用法示例。
在下文中一共展示了log.DEBUG屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def main():
priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
zun_service.prepare_service(sys.argv)
LOG.info('Starting server in PID %s', os.getpid())
CONF.log_opt_values(LOG, logging.DEBUG)
CONF.import_opt('topic', 'zun.conf.compute', group='compute')
from zun.compute import manager as compute_manager
endpoints = [
compute_manager.Manager(),
]
server = rpc_service.Service.create(CONF.compute.topic, CONF.host,
endpoints, binary='zun-compute')
launcher = service.launch(CONF, server, restart_method='mutate')
launcher.wait()
示例2: setup_app
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def setup_app(pecan_config=None, debug=False, argv=None):
"""Creates and returns a pecan wsgi app."""
if argv is None:
argv = sys.argv
octavia_service.prepare_service(argv)
cfg.CONF.log_opt_values(LOG, logging.DEBUG)
_init_drivers()
if not pecan_config:
pecan_config = get_pecan_config()
pecan_configuration.set_config(dict(pecan_config), overwrite=True)
return pecan_make_app(
pecan_config.app.root,
wrap_app=_wrap_app,
debug=debug,
hooks=pecan_config.app.hooks,
wsme=pecan_config.wsme
)
示例3: retry
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def retry(exceptions, interval=1, retries=3, backoff_rate=2):
if retries < 1:
raise ValueError(_('Retries must be greater than or '
'equal to 1 (received: %s). ') % retries)
def _decorator(f):
@six.wraps(f)
def _wrapper(*args, **kwargs):
r = tenacity.Retrying(
before_sleep=tenacity.before_sleep_log(LOG, logging.DEBUG),
after=tenacity.after_log(LOG, logging.DEBUG),
stop=tenacity.stop_after_attempt(retries),
reraise=True,
retry=tenacity.retry_if_exception_type(exceptions),
wait=tenacity.wait_exponential(
multiplier=interval, min=0, exp_base=backoff_rate))
return r.call(f, *args, **kwargs)
return _wrapper
return _decorator
示例4: test_pass_args_to_log
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def test_pass_args_to_log(self):
a = SavingAdapter(self.mock_log, {})
message = 'message'
exc_message = 'exception'
val = 'value'
a.log(logging.DEBUG, message, name=val, exc_info=exc_message)
expected = {
'exc_info': exc_message,
'extra': {'name': val, 'extra_keys': ['name']},
}
actual = a.results[0]
self.assertEqual(message, actual[0])
self.assertEqual(expected, actual[1])
results = actual[2]
self.assertEqual(message, results[0])
self.assertEqual(expected, results[1])
示例5: initialize_application
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def initialize_application():
conf_files = _get_config_files()
api_config.parse_args([], default_config_files=conf_files)
logging.setup(CONF, "masakari")
objects.register_all()
CONF(sys.argv[1:], project='masakari', version=version.version_string())
# NOTE: Dump conf at debug (log_options option comes from oslo.service)
# This is gross but we don't have a public hook into oslo.service to
# register these options, so we are doing it manually for now;
# remove this when we have a hook method into oslo.service.
CONF.register_opts(service_opts.service_opts)
if CONF.log_options:
CONF.log_opt_values(logging.getLogger(__name__), logging.DEBUG)
config.set_middleware_defaults()
rpc.init(CONF)
conf = conf_files[0]
return deploy.loadapp('config:%s' % conf, name="masakari_api")
示例6: setup_logging
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def setup_logging(self):
# Assign default logs to self.LOG so we can still
# assert on senlin logs.
default_level = logging.INFO
if os.environ.get('OS_DEBUG') in _TRUE_VALUES:
default_level = logging.DEBUG
self.LOG = self.useFixture(
fixtures.FakeLogger(level=default_level, format=_LOG_FORMAT))
base_list = set([nlog.split('.')[0] for nlog in
logging.getLogger().logger.manager.loggerDict])
for base in base_list:
if base in TEST_DEFAULT_LOGLEVELS:
self.useFixture(fixtures.FakeLogger(
level=TEST_DEFAULT_LOGLEVELS[base],
name=base, format=_LOG_FORMAT))
elif base != 'senlin':
self.useFixture(fixtures.FakeLogger(
name=base, format=_LOG_FORMAT))
示例7: init_application
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def init_application():
# NOTE(hberaud): Call reset to ensure the ConfigOpts object doesn't
# already contain registered options if the app is reloaded.
CONF.reset()
# Initialize the oslo configuration library and logging
service.prepare_service(sys.argv)
profiler.setup('zun-api', CONF.host)
LOG.debug("Configuration:")
CONF.log_opt_values(LOG, log.DEBUG)
return app.load_app()
示例8: _debug_log_for_routes
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def _debug_log_for_routes(self, msg, routes, bgp_speaker_id):
# Could have a large number of routes passed, check log level first
if LOG.isEnabledFor(logging.DEBUG):
for route in routes:
LOG.debug(msg, route, bgp_speaker_id)
示例9: test_record_logs_dependencies
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def test_record_logs_dependencies(self):
entry = db.create_pending_row(self.db_context, *self.UPDATE_ROW)
logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
journal.record(self.db_context, *self.UPDATE_ROW)
self.assertIn(str(entry.seqnum), logger.output)
示例10: _sg_callback
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def _sg_callback(self, callback, resource, event, trigger, **kwargs):
if 'payload' in kwargs:
# TODO(boden): remove shim once all callbacks use payloads
context = kwargs['payload'].context
res = kwargs['payload'].desired_state
res_id = kwargs['payload'].resource_id
copy_kwargs = kwargs
else:
context = kwargs['context']
res = kwargs.get(resource)
res_id = kwargs.get("%s_id" % resource)
copy_kwargs = kwargs.copy()
copy_kwargs.pop('context')
if res_id is None:
res_id = res.get('id')
odl_res_type = _RESOURCE_MAPPING[resource]
odl_ops = _OPERATION_MAPPING[event]
odl_res_dict = None if res is None else {odl_res_type.singular: res}
_log_on_callback(logging.DEBUG, "Calling callback", odl_ops,
odl_res_type, res_id, odl_res_dict, copy_kwargs)
try:
callback(context, odl_ops, odl_res_type, res_id, odl_res_dict,
**copy_kwargs)
except Exception as e:
# In case of precommit, neutron registry notification caller
# doesn't log its exception. In networking-odl case, we don't
# normally throw exception. So log it here for debug
with excutils.save_and_reraise_exception():
if not db_api.is_retriable(e):
_log_on_callback(logging.ERROR, "Exception from callback",
odl_ops, odl_res_type, res_id,
odl_res_dict, copy_kwargs)
示例11: main
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def main():
magnum_service.prepare_service(sys.argv)
gmr.TextGuruMeditation.setup_autorun(version)
LOG.info('Starting server in PID %s', os.getpid())
LOG.debug("Configuration:")
CONF.log_opt_values(LOG, logging.DEBUG)
conductor_id = short_id.generate_id()
endpoints = [
indirection_api.Handler(),
cluster_conductor.Handler(),
conductor_listener.Handler(),
ca_conductor.Handler(),
federation_conductor.Handler(),
nodegroup_conductor.Handler(),
]
server = rpc_service.Service.create(CONF.conductor.topic,
conductor_id, endpoints,
binary='magnum-conductor')
workers = CONF.conductor.workers
if not workers:
workers = processutils.get_worker_count()
launcher = service.launch(CONF, server, workers=workers)
# NOTE(mnaser): We create the periodic tasks here so that they
# can be attached to the main process and not
# duplicated in all the children if multiple
# workers are being used.
server.create_periodic_tasks()
server.start()
launcher.wait()
示例12: main
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def main():
service.prepare_service(sys.argv)
gmr.TextGuruMeditation.setup_autorun(version)
# Enable object backporting via the conductor
base.MagnumObject.indirection_api = base.MagnumObjectIndirectionAPI()
app = api_app.load_app()
# Setup OSprofiler for WSGI service
profiler.setup('magnum-api', CONF.host)
# SSL configuration
use_ssl = CONF.api.enabled_ssl
# Create the WSGI server and start it
host, port = CONF.api.host, CONF.api.port
LOG.info('Starting server in PID %s', os.getpid())
LOG.debug("Configuration:")
CONF.log_opt_values(LOG, logging.DEBUG)
LOG.info('Serving on %(proto)s://%(host)s:%(port)s',
dict(proto="https" if use_ssl else "http", host=host, port=port))
workers = CONF.api.workers
if not workers:
workers = processutils.get_worker_count()
LOG.info('Server will handle each request in a new process up to'
' %s concurrent processes', workers)
serving.run_simple(host, port, app, processes=workers,
ssl_context=_get_ssl_configs(use_ssl))
示例13: _get_connection
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def _get_connection(self):
"""Context manager providing a netmiko SSH connection object.
This function hides the complexities of gracefully handling retrying
failed connection attempts.
"""
retry_exc_types = (paramiko.SSHException, EOFError)
# Use tenacity to handle retrying.
@tenacity.retry(
# Log a message after each failed attempt.
after=tenacity.after_log(LOG, logging.DEBUG),
# Reraise exceptions if our final attempt fails.
reraise=True,
# Retry on SSH connection errors.
retry=tenacity.retry_if_exception_type(retry_exc_types),
# Stop after the configured timeout.
stop=tenacity.stop_after_delay(
int(self.ngs_config['ngs_ssh_connect_timeout'])),
# Wait for the configured interval between attempts.
wait=tenacity.wait_fixed(
int(self.ngs_config['ngs_ssh_connect_interval'])),
)
def _create_connection():
return netmiko.ConnectHandler(**self.config)
# First, create a connection.
try:
net_connect = _create_connection()
except tenacity.RetryError as e:
LOG.error("Reached maximum SSH connection attempts, not retrying")
raise exc.GenericSwitchNetmikoConnectError(
config=device_utils.sanitise_config(self.config), error=e)
except Exception as e:
LOG.error("Unexpected exception during SSH connection")
raise exc.GenericSwitchNetmikoConnectError(
config=device_utils.sanitise_config(self.config), error=e)
# Now yield the connection to the caller.
with net_connect:
yield net_connect
示例14: check_for_setup_error
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def check_for_setup_error(self):
try:
# Log the source SHA for support. Only do this with DEBUG.
if LOG.isEnabledFor(log.DEBUG):
LOG.debug('HPE3ParShareDriver SHA1: %s',
self.sha1_hash(HPE3ParShareDriver))
LOG.debug('HPE3ParMediator SHA1: %s',
self.sha1_hash(hpe_3par_mediator.HPE3ParMediator))
except Exception as e:
# Don't let any exceptions during the SHA1 logging interfere
# with startup. This is just debug info to identify the source
# code. If it doesn't work, just log a debug message.
LOG.debug('Source code SHA1 not logged due to: %s',
six.text_type(e))
示例15: wait
# 需要導入模塊: from oslo_log import log [as 別名]
# 或者: from oslo_log.log import DEBUG [as 別名]
def wait():
CONF.log_opt_values(LOG, log.DEBUG)
try:
_launcher.wait()
except KeyboardInterrupt:
_launcher.stop()
rpc.cleanup()