Change-Id: I0f458b4dd8996e1fe9fc22f48edd36493515980e
This commit is contained in:
Likitha Shetty 2011-11-21 10:31:25 +05:30
parent 356ec71306
commit 6b1df267d0
2 changed files with 8 additions and 2 deletions

View File

@ -82,6 +82,7 @@ Kevin Bringard <kbringard@attinteractive.com>
Kevin L. Mitchell <kevin.mitchell@rackspace.com>
Kirill Shileev <kshileev@gmail.com>
Koji Iida <iida.koji@lab.ntt.co.jp>
Likitha Shetty <likitha.shetty@citrix.com>
Loganathan Parthipan <parthipan@hp.com>
Lorin Hochstein <lorin@isi.edu>
Lvov Maxim <usrleon@gmail.com>

View File

@ -70,6 +70,7 @@ flags.DEFINE_list('default_log_levels',
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')
# A list of things we want to replicate from logging.
@ -243,7 +244,7 @@ class NovaRootLogger(NovaLogger):
def __init__(self, name, level=NOTSET):
self.logpath = None
self.filelog = None
self.streamlog = StreamHandler()
self.streamlog = None
self.syslog = None
NovaLogger.__init__(self, name, level)
@ -258,7 +259,6 @@ class NovaRootLogger(NovaLogger):
self.addHandler(self.syslog)
logpath = _get_log_file_path()
if logpath:
self.removeHandler(self.streamlog)
if logpath != self.logpath:
self.removeHandler(self.filelog)
self.filelog = WatchedFileHandler(logpath)
@ -271,6 +271,11 @@ class NovaRootLogger(NovaLogger):
os.chmod(self.logpath, mode)
else:
self.removeHandler(self.filelog)
if self.streamlog:
self.removeHandler(self.streamlog)
self.streamlog = None
if FLAGS.use_stderr:
self.streamlog = StreamHandler()
self.addHandler(self.streamlog)
if FLAGS.publish_errors:
self.addHandler(PublishErrorsHandler(ERROR))