S
skunkwerk
i'm redirecting the stdout & stderr of my python program to a log.
Tests i've done on a simple program with print statements, etc. work
fine. however, in my actual program i get weird output like this:
2008-05-04 20:20:44,790 DEBUG Grabbing message from queue, if any
2008-05-04 20:20:44,790 DEBUG DEBUG:doit:Grabbing message from queue,
if any
2008-05-04 20:20:44,790 DEBUG DEBUG:doitEBUG:doit:Grabbing message
from queue, if any
2008-05-04 20:20:44,790 DEBUG
DEBUG:doitEBUG:doitEBUG:doit:Grabbing message from queue, if any
followed by:
2008-05-04 20:20:44,815 DEBUG DEBUG:doit:Traceback (most recent call
last):
2008-05-04 20:20:44,815 DEBUG DEBUG:doitEBUG:doit:Traceback (most
recent call last):
2008-05-04 20:20:44,815 DEBUG
DEBUG:doitEBUG:doitEBUG:doit:Traceback (most recent call last):
the code I'm using for the log stuff:
import logging
logger = logging.getLogger('doit')
hdlr = logging.FileHandler('/home/imran/doit.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
class write2Log:
def write(self, x):
if x!='\n':
logger.debug(str(x))
sys.stdout = write2Log()
sys.stderr= write2Log()
any ideas what might be causing the problems? some of the messages
being output are quite long - might this be a problem?
thanks
Tests i've done on a simple program with print statements, etc. work
fine. however, in my actual program i get weird output like this:
2008-05-04 20:20:44,790 DEBUG Grabbing message from queue, if any
2008-05-04 20:20:44,790 DEBUG DEBUG:doit:Grabbing message from queue,
if any
2008-05-04 20:20:44,790 DEBUG DEBUG:doitEBUG:doit:Grabbing message
from queue, if any
2008-05-04 20:20:44,790 DEBUG
DEBUG:doitEBUG:doitEBUG:doit:Grabbing message from queue, if any
followed by:
2008-05-04 20:20:44,815 DEBUG DEBUG:doit:Traceback (most recent call
last):
2008-05-04 20:20:44,815 DEBUG DEBUG:doitEBUG:doit:Traceback (most
recent call last):
2008-05-04 20:20:44,815 DEBUG
DEBUG:doitEBUG:doitEBUG:doit:Traceback (most recent call last):
the code I'm using for the log stuff:
import logging
logger = logging.getLogger('doit')
hdlr = logging.FileHandler('/home/imran/doit.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
class write2Log:
def write(self, x):
if x!='\n':
logger.debug(str(x))
sys.stdout = write2Log()
sys.stderr= write2Log()
any ideas what might be causing the problems? some of the messages
being output are quite long - might this be a problem?
thanks