Bug 884863: nova logs everything to syslog twice

Fix double-registration of the syslog handler.
NovaRootLogger.setup_from_flags is called twice from log.setup() -- once
through NovaRootLogger.__init__ and once through reset().  setup_from_flags
wasn't idempotent, so this resulted in the syslog handler being registered
twice.

Rather than fix the twisty-turny maze that is setup(), I've opted to make
setup_from_flags idempotent in this regard, by always unregistering the
syslog handler before doing anything else.

Change-Id: I59ad61751e1a19d2cbb73dc1deea9c708d4c5032
This commit is contained in:
Ewan Mellor
2011-11-01 11:54:59 -07:00
parent 550726af20
commit 4be5abe3a8

View File

@@ -245,11 +245,12 @@ class NovaRootLogger(NovaLogger):
def setup_from_flags(self):
"""Setup logger from flags."""
global _filelog
if self.syslog:
self.removeHandler(self.syslog)
self.syslog = None
if FLAGS.use_syslog:
self.syslog = SysLogHandler(address='/dev/log')
self.addHandler(self.syslog)
elif self.syslog:
self.removeHandler(self.syslog)
logpath = _get_log_file_path()
if logpath:
self.removeHandler(self.streamlog)