Source line number for log purpose (newbie)

François Pinard pinard at iro.umontreal.ca
Sat Sep 25 18:29:04 EDT 1999


Siggy Brentrup <bsb at baal.infodrom.north.de> writes:

> It's easy, feel free to use the attached code (quoted-printable to get 
> tabs right)

Last week, I did something a bit more elaborate, but based on the same
trick.  The problem is that between the interesting source line and the
diagnostic, there might be a chain of intermediate routine calls, showing
no real interest.  You'll find the code below.  I use it through:

        Report.oops(format, args...)

like calls, from a bit everywhere in my code.  Each `def foo()...'
which is uninteresting for diagnostic purposes has the following line:

        Report.untangible(foo)

after it, before the next `def'.

I made some effort to get a very legible log.  All successive log lines
issued from within the same interesting spot in the program have the program
location suppressed, but the margin preserved.  The program location is
repeated in full when the line change.  Moreover, if another set of log
lines come from another module, an extra white line is added for grouping.

The few French comments should not create any problem, I guess.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Report.py
Type: application/octet-stream
Size: 2485 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/19990925/70f84fe5/attachment.obj>
-------------- next part --------------

-- 
Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard


More information about the Python-list mailing list