Collection console output

MRAB python at mrabarnett.plus.com
Wed Sep 16 17:14:28 EDT 2009


Esben von Buchwald wrote:
> Hello
> 
> Are there any simple ways to collect the data, python prints to the 
> console when running an app?
> 
> I'm doing som apps for S60 mobile phones and can't see the console, when 
> the UI is running, but i'd like to collect the output, to look for 
> eventual exceptions etc.
> 
> Cant it be redirected to a log file, just like when runing a script in 
> unix, where you say $ ./script.pl > logfile.txt ?

Does the S60 support a command line like *nix and Windows?

An alternative from within the script is:

     import sys

     sys.stdout = open(log_path, "w")


You might also want to capture stderr:

     import sys

     log_file = open(log_path, "w")
     sys.stdout = log_file
     sys.stderr = log_file



More information about the Python-list mailing list