[Zodb-checkins] CVS: Packages/ZEO - zeolog.py:1.1.2.2
jeremy@digicool.com
jeremy@digicool.com
Wed, 25 Apr 2001 16:33:36 -0400 (EDT)
Update of /cvs-repository/Packages/ZEO
In directory korak:/tmp/cvs-serv27942
Modified Files:
Tag: ZEO-ZRPC-Dev
zeolog.py
Log Message:
add support for printing tracebacks if the error argument is passsed
--- Updated File zeolog.py in package Packages/ZEO --
--- zeolog.py 2001/04/20 19:14:09 1.1.2.1
+++ zeolog.py 2001/04/25 20:33:35 1.1.2.2
@@ -3,6 +3,7 @@
import os
import sys
import time
+import traceback
# the logging severity constants defined by zLOG
from zLOG import TRACE, DEBUG, BLATHER, INFO, PROBLEM, WARNING, ERROR, PANIC
@@ -25,6 +26,12 @@
def LOG(subsys, severity, summary, detail='', error=None,
reraise=None):
+ """Print log info to current file.
+
+ The error argument should be a 3-tuple as returned by
+ sys.exc_info(). A formatted traceback will be printed to the file
+ in addition to the summary.
+ """
if log_file is None or severity < log_level:
return
s = "%s %7s %s %s" % (now(), severity_strings[severity], subsys, summary)
@@ -34,7 +41,11 @@
log_file.flush()
if error:
- pass # XXX haven't implemented traceback writing
+ lines = traceback.format_exception(*error)
+ # each line ends with a newline, hence the comma
+ print >> log_file, "".join(lines),
+ print >> log_file, "-" * 70
+ log_file.flush()
if reraise and error:
raise error[0], error[1], error[2]