From 6b1df267d0a9b7d62e06e1c3d0b5483c6a64598e Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Mon, 21 Nov 2011 10:31:25 +0530 Subject: [PATCH] Fix Bug #891718 Change-Id: I0f458b4dd8996e1fe9fc22f48edd36493515980e --- Authors | 1 + nova/log.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Authors b/Authors index 36ec620cdeb3..10d492a323f7 100644 --- a/Authors +++ b/Authors @@ -82,6 +82,7 @@ Kevin Bringard Kevin L. Mitchell Kirill Shileev Koji Iida +Likitha Shetty Loganathan Parthipan Lorin Hochstein Lvov Maxim diff --git a/nova/log.py b/nova/log.py index 2121933abb5e..6826c231136c 100644 --- a/nova/log.py +++ b/nova/log.py @@ -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))