Commit ae145fea authored by Guido van Rossum's avatar Guido van Rossum

Don't shoot me. I got tired of reading long log lines in an 80-char

wide xterm or emacs window.  So now, when using Python 2.3 or later,
the textwrap module is used to wrap the message line, indenting
subsequent lines past the timestamp.  Details and tracebacks are left
alone.
parent 66ede20d
...@@ -11,10 +11,15 @@ ...@@ -11,10 +11,15 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.14 $'[11:-2] __version__='$Revision: 1.15 $'[11:-2]
import os, sys, time import os, sys, time
try:
import textwrap
except ImportError:
textwrap = None
from FormatException import format_exception from FormatException import format_exception
def severity_string(severity, mapping={ def severity_string(severity, mapping={
...@@ -75,9 +80,13 @@ class stupid_log_write: ...@@ -75,9 +80,13 @@ class stupid_log_write:
def log(self, subsystem, severity, summary, detail, error): def log(self, subsystem, severity, summary, detail, error):
if _log_dest is None or severity < _log_level: if _log_dest is None or severity < _log_level:
return return
buf = ["------", buf = ["------"]
"%s %s %s %s" % line = ("%s %s %s %s" %
(log_time(), severity_string(severity), subsystem, summary)] (log_time(), severity_string(severity), subsystem, summary))
if not textwrap or len(line) < 80:
buf.append(line)
else:
buf.extend(textwrap.wrap(line, subsequent_indent=" "*20))
if detail: if detail:
buf.append(str(detail)) buf.append(str(detail))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment