interactive-logging

Arne Mueller a.mueller at icrf.icnet.uk
Wed Jun 23 14:02:54 EDT 1999


meow wrote:
> 
> Magnus L Hetland <mlh at idt.ntnu.no> writes:
> 
> > Arne Mueller <a.mueller at icrf.icnet.uk> writes:
> >> 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.
> 
> > Hm. Isn't there a UN*X command that does that? (That logs everything
> > going on in a terminal...)
> 
> 'python | tee log.file' would be a simple way to get that kind of
> thing.
Right! Thanks very much, simple and very effective solution ... I
completely forgot about good old tee ;-)

my interactive session:

bash% python 2>&1 | tee python.log 
Python 1.5.2 (#14, Jun 23 1999, 04:05:01)  [GCC egcs-2.91.66 19990314
(egcs-1.1.2  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
python> x = [1,2,3,4,5]
python> x
[1, 2, 3, 4, 5]
python> for i in x:
...     print i
... 
1
2
3
4
5
python> 
python> 
python> 
python> fir in a:
  File "<stdin>", line 1
    fir in a:
            ^
SyntaxError: invalid syntax
python> 
python> 


and now look in python.log:

bash% cat python.log 
Python 1.5.2 (#14, Jun 23 1999, 04:05:01)  [GCC egcs-2.91.66 19990314
(egcs-1.1.2  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
python> x = [1,2,3,4,5]
python> x
[1, 2, 3, 4, 5]
python> for i in x:
...     print i
... 
1
2
3
4
5
python> 
python> 
python> 
python> fir in a:
  File "<stdin>", line 1
    fir in a:
            ^
SyntaxError: invalid syntax
python> 
python> 


        thans,

        Arne




More information about the Python-list mailing list