Collection console output

E

Esben von Buchwald

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 ?
 
M

MRAB

Esben said:
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
 
E

Esben von Buchwald

MRAB said:
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

Thanks a lot - it works fine :)

I've made this class which works perfectly

class Consolefile:
def __init__(self):
self.file=None
self.status='init'
def start(self):
self.filename="%s\\%s_console.log"%(cfg.logdir,FILEID)
print self.filename
self.oldstderr=sys.stderr
self.oldstdout=sys.stdout
self.file=open(self.filename,'w')
print >> self.file, '#Logging STDERR and STDOUT to this file'
sys.stderr=self.file
sys.stdout=self.file
self.status='started'
def stop(self):
print >> self.file, '#Console logging stopped'
sys.stderr=self.oldstderr
sys.stdout=self.oldstdout
self.file.close()
self.status='stopped'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top