diff options
author | Mark McLoughlin <markmc@redhat.com> | 2012-01-23 11:51:14 +0000 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2012-01-28 12:37:16 +0000 |
commit | 82049af90e86380043c59741fa4e1cd2cf24aaa7 (patch) | |
tree | fd5a35b7a373de888ece003929f8c499b34ce83c /nova/log.py | |
parent | 02b872625b94c3c63674d8c64b23f80215b04a15 (diff) | |
download | nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.gz nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.xz nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.zip |
Refactor away the flags.DEFINE_* helpers
The next obvious step in porting to cfg is to define all options using
cfg schemas directly rather than using the flags.DEFINE_* helpers.
This is a large change, but it is almost entirely pure refactoring and
does not result in any functional changes.
The only change to note is that the default values for glance_host,
glance_api_servers and default_publisher_id options are now using opt
value interpolation i.e.
-glance_host=_get_my_ip()
+glance_host='$my_ip'
-glance_api_servers=['%s:%d' % (FLAGS.glance_host, FLAGS.glance_port)]
+glance_api_servers=['$glance_host:$glance_port']
-default_publisher_id=FLAGS.host
+default_publisher_id='$host'
Also note that the lower_bound check on the {report,periodic}_interval
options are no more, but this has been true since cfg was first added.
Change-Id: Ia58c8f0aaf61628bb55b1b8485118a2a9852ed17
Diffstat (limited to 'nova/log.py')
-rw-r--r-- | nova/log.py | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/nova/log.py b/nova/log.py index 8400f7000..8052f79a8 100644 --- a/nova/log.py +++ b/nova/log.py @@ -38,40 +38,52 @@ import sys import traceback import nova +from nova.common import cfg from nova import flags from nova import local from nova import version -FLAGS = flags.FLAGS -flags.DEFINE_string('logging_context_format_string', - '%(asctime)s %(levelname)s %(name)s ' - '[%(request_id)s %(user_id)s ' - '%(project_id)s] %(message)s', - 'format string to use for log messages with context') -flags.DEFINE_string('logging_default_format_string', - '%(asctime)s %(levelname)s %(name)s [-] ' - '%(message)s', - 'format string to use for log messages without context') -flags.DEFINE_string('logging_debug_format_suffix', - 'from (pid=%(process)d) %(funcName)s' - ' %(pathname)s:%(lineno)d', - 'data to append to log format when level is DEBUG') -flags.DEFINE_string('logging_exception_prefix', - '(%(name)s): TRACE: ', - 'prefix each line of exception output with this format') -flags.DEFINE_list('default_log_levels', - ['amqplib=WARN', - 'sqlalchemy=WARN', - 'boto=WARN', - 'suds=INFO', - 'eventlet.wsgi.server=WARN'], - 'list of logger=LEVEL pairs') -flags.DEFINE_bool('use_syslog', False, 'output to syslog') -flags.DEFINE_bool('publish_errors', False, 'publish error events') -flags.DEFINE_string('logfile', None, 'output to named file') -flags.DEFINE_bool('use_stderr', True, 'log to standard error') +log_opts = [ + cfg.StrOpt('logging_context_format_string', + default='%(asctime)s %(levelname)s %(name)s [%(request_id)s ' + '%(user_id)s %(project_id)s] %(message)s', + help='format string to use for log messages with context'), + cfg.StrOpt('logging_default_format_string', + default='%(asctime)s %(levelname)s %(name)s [-] %(message)s', + help='format string to use for log messages without context'), + cfg.StrOpt('logging_debug_format_suffix', + default='from (pid=%(process)d) %(funcName)s ' + '%(pathname)s:%(lineno)d', + help='data to append to log format when level is DEBUG'), + cfg.StrOpt('logging_exception_prefix', + default='(%(name)s): TRACE: ', + help='prefix each line of exception output with this format'), + cfg.ListOpt('default_log_levels', + default=[ + 'amqplib=WARN', + 'sqlalchemy=WARN', + 'boto=WARN', + 'suds=INFO', + 'eventlet.wsgi.server=WARN' + ], + help='list of logger=LEVEL pairs'), + cfg.BoolOpt('use_syslog', + default=False, + help='output to syslog'), + cfg.BoolOpt('publish_errors', + default=False, + help='publish error events'), + cfg.StrOpt('logfile', + default=None, + help='output to named file'), + cfg.BoolOpt('use_stderr', + default=True, + help='log to standard error'), + ] +FLAGS = flags.FLAGS +FLAGS.add_options(log_opts) # A list of things we want to replicate from logging. # levels |