[Zope-Checkins] CVS: Zope/lib/python/zLOG - MinimalLogger.py:1.13.4.3
Chris McDonough
chrism@zope.com
Tue, 8 Oct 2002 17:45:58 -0400
Update of /cvs-repository/Zope/lib/python/zLOG
In directory cvs.zope.org:/tmp/cvs-serv17057/lib/python/zLOG
Modified Files:
Tag: chrism-install-branch
MinimalLogger.py
Log Message:
More merges from HEAD.
=== Zope/lib/python/zLOG/MinimalLogger.py 1.13.4.2 => 1.13.4.3 ===
--- Zope/lib/python/zLOG/MinimalLogger.py:1.13.4.2 Tue Oct 8 14:41:16 2002
+++ Zope/lib/python/zLOG/MinimalLogger.py Tue Oct 8 17:45:57 2002
@@ -15,6 +15,11 @@
import os, sys, time
+try:
+ import textwrap
+except ImportError:
+ textwrap = None
+
from FormatException import format_exception
def severity_string(severity, mapping={
@@ -75,24 +80,32 @@
def log(self, subsystem, severity, summary, detail, error):
if _log_dest is None or severity < _log_level:
return
+ buf = ["------"]
+ line = ("%s %s %s %s" %
+ (log_time(), severity_string(severity), subsystem, summary))
+ if not textwrap or len(line) < 80:
+ buf.append(line)
+ else:
+ buf.extend(textwrap.wrap(line,
+ width=79,
+ subsequent_indent=" "*20,
+ break_long_words=0))
if detail:
- buf = ("------\n"
- "%s %s %s %s\n%s" % (log_time(), severity_string(severity),
- subsystem, summary, detail))
- else:
- buf = ("------\n"
- "%s %s %s %s" % (log_time(), severity_string(severity),
- subsystem, summary))
- print >> _log_dest, buf
+ buf.append(str(detail))
if error:
try:
lines = format_exception(error[0], error[1], error[2],
limit=100)
- print >> _log_dest, ''.join(lines)
- except:
- print >> _log_dest, "%s: %s" % error[:2]
+ buf.append(''.join(lines))
+ except '':
+ buf.append("%s: %s" % error[:2])
+
+ if buf[-1] and buf[-1][-1] != "\n":
+ buf.append("") # Cause a final \n to be appended
+
+ _log_dest.write("\n".join(buf))
_log_dest.flush()