From a521d9beb72f82bd9f0ffe49853e3a1c6edfe3ce Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Mon, 27 Feb 2006 21:35:25 +0000 Subject: Fix problems reported by Rick and Pedro git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1774 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Logging.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Logging.py b/src/lib/Logging.py index afaed1c96..60f5e98df 100644 --- a/src/lib/Logging.py +++ b/src/lib/Logging.py @@ -61,6 +61,8 @@ class TermiosFormatter(logging.Formatter): for i in xrange(inner_lines): returns.append("%s" % (line[i*line_len:(i+1)*line_len])) elif type(record.msg) == types.ListType: + if not record.msg: + return '' record.msg.sort() msgwidth = self.width columnWidth = max([len(item) for item in record.msg]) @@ -111,17 +113,17 @@ def setup_logging(procname, to_console=True, to_syslog=True, syslog_facility='lo '''setup logging for bcfg2 software''' if hasattr(logging, 'already_setup'): return - console = logging.StreamHandler() - console.setLevel(logging.DEBUG) - # tell the handler to use this format - console.setFormatter(TermiosFormatter()) - syslog = FragmentingSysLogHandler(procname, '/dev/log', syslog_facility) - syslog.setLevel(logging.DEBUG) - syslog.setFormatter(logging.Formatter('%(name)s[%(process)d]: %(message)s')) # add the handler to the root logger if to_console: + console = logging.StreamHandler() + console.setLevel(logging.DEBUG) + # tell the handler to use this format + console.setFormatter(TermiosFormatter()) logging.root.addHandler(console) if to_syslog: + syslog = FragmentingSysLogHandler(procname, '/dev/log', syslog_facility) + syslog.setLevel(logging.DEBUG) + syslog.setFormatter(logging.Formatter('%(name)s[%(process)d]: %(message)s')) logging.root.addHandler(syslog) logging.root.setLevel(level) logging.already_setup = True -- cgit v1.2.3-1-g7c22