interactive-logging
Arne Mueller
a.mueller at icrf.icnet.uk
Tue Jun 22 16:22:50 EDT 1999
Hi All,
I'd like to add some logging to the interpreter's interactive modus so
that everything I type in and everything what's printed to the screen
(errors and 'normal' output) is copied to a log-file.
Usage could be as follows:
Python 1.5.2b2 (#11, Jun 3 1999, 17:27:58) [C] on irix646
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
python> import ilogger
python> ilogger('lastputhon.log')
python> x = [1,2,3,4,5]
python> for i in x:
... print i
...
1
2
3
4
5
python> for i x:
File "<stdin>", line 1
for i x:
^
SyntaxError: invalid syntax
python>
This interactive session should than be written to 'lastputhon.log' e.g:
# python session from mueller at jumbo
# Tue Jun 22 21:13:47 BST 1999
x = [1,2,3,4,5]
for i in x:
print i
out>
out> 1
out> 2
out> 3
out> 4
out> 5
error> for i x:
error> File "<stdin>", line 1
error> for i x:
error> ^
error> SyntaxError: invalid syntax
It's easy to parse the log-file for normal output indicated by 'out>'
and for erros. The normal python-prompt and the '...' in the loop-body
is removed.
Is there already something like this written? I've no idea how how the
interactive modus works. For aprogram I've written that copies a
file-object, say everything that goes to 'sys.stderr' is also written to
a log-file, how to do that interactive modus?
thanks very much,
Arne
More information about the Python-list
mailing list