I created a simple UI for my application using curses and I also include logs (logging) in my modules using herarchy structure (logmain, logmain.child1) and so on.
In case an log event occurs the log is displayed in my UI,distroying its apparence. I also created a pad (myLogPad) in order toput there the incoming logs, but without success. How I can intercept the log event and print it in a specific area (last line) of my screen?
def setupLogger(name,file_name):
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
#formatter = logging.Formatter(
# "%(asctime)s %(threadName)-11s %(levelname)-10s %(message)s")
formatter = logging.Formatter('%(asctime) -25s - %(name) -15s - %(levelname) -10s - %(message)s')
formatterDisplay = logging.Formatter('%(asctime)-8s|%(name)-12s|%(levelname)-6s|%(message)-s', '%H:%M:%S')
# Alternative formatting available on python 3.2+:
# formatter = logging.Formatter(
# "{asctime} {threadName:>11} {levelname} {message}", style='{')
# Log to file
filehandler = logging.FileHandler(file_name, 'w')
filehandler.setFormatter(formatter)
logger.addHandler(filehandler)
# Log to stdout too
streamhandler = logging.StreamHandler()
streamhandler.setFormatter(formatterDisplay)
logger.addHandler(streamhandler)
I try to pass mylog pad in the streamhandler = logging.StreamHandler() but without sucess. Any idea? Thank you