summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-02-27 21:35:25 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-02-27 21:35:25 +0000
commita521d9beb72f82bd9f0ffe49853e3a1c6edfe3ce (patch)
treee4b7392d84d67e692d132340867c7f12d85588fc /src/lib
parent9e19b48f3213af71b63432800cc66fedeb4c000d (diff)
downloadbcfg2-a521d9beb72f82bd9f0ffe49853e3a1c6edfe3ce.tar.gz
bcfg2-a521d9beb72f82bd9f0ffe49853e3a1c6edfe3ce.tar.bz2
bcfg2-a521d9beb72f82bd9f0ffe49853e3a1c6edfe3ce.zip
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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Logging.py16
1 files changed, 9 insertions, 7 deletions
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