Commit e66bb7a3 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 8b3a867c
......@@ -11,10 +11,15 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__version__='$Revision: 1.14 $'[11:-2]
__version__='$Revision: 1.15 $'[11:-2]
import os, sys, time
try:
import textwrap
except ImportError:
textwrap = None
from FormatException import format_exception
def severity_string(severity, mapping={
......@@ -75,9 +80,13 @@ class stupid_log_write:
def log(self, subsystem, severity, summary, detail, error):
if _log_dest is None or severity < _log_level:
return
buf = ["------",
"%s %s %s %s" %
(log_time(), severity_string(severity), subsystem, summary)]
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, subsequent_indent=" "*20))
if 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