logging module

W

Werner F. Bruhin

I am starting to use the logging module.

Simple log to file and/or console work very nicely.

Even managed to get TimedRotatingFileHandler to work.

The problem I am trying to solve.

1. I would like to have a "log viewer" a wxPython based app to be able
to look at a log generated by another script.

Did a little test for this.
- log_testing.py attached is generating the log entries
- log_viewerConsole.py is trying to attach to the same logger (would
convert/change this to a wxPython app)

The log_viewerConsole script only sees the logs it generates. Does this
script have to be started by the first one to get the same logger?

Any hints on how to solve my problem would be very appreciated.

Werner



[formatters]
keys=simple

[handlers]
keys=consoleHandler,fileRollOver,ntEventLog

[loggers]
keys=root,frollover

[formatter_simple]
format=%(name)s:%(levelname)s %(module)s: %(lineno)d: %(asctime)s: %(message)s

[handler_consoleHandler]
class=StreamHandler
args=[]
formatter=simple

[handler_fileRollOver]
class=handlers.TimedRotatingFileHandler
args=['./logs/pyg_log.txt', 'M', 30, 5]
formatter=simple

[handler_ntEventLog]
class=handlers.SysLogHandler
args=[("localhost",handlers.SYSLOG_UDP_PORT),handlers.SysLogHandler.LOG_USER]
formatter=simple

[logger_root]
level=DEBUG
handlers=ntEventLog

[logger_frollover]
level=DEBUG
handlers=fileRollOver
qualname=loggerFRO
 
M

Matimus

I am starting to use the logging module.

Simple log to file and/or console work very nicely.

Even managed to get TimedRotatingFileHandler to work.

The problem I am trying to solve.

1. I would like to have a "log viewer" a wxPython based app to be able
to look at a log generated by another script.

Running in a separate process? That isn't possible. Okay, well, it
isn't possible without doing a fair amount of work on your own. You
would probably need to create a handler that writes everything to a
pipe or a socket, and then have your second application read from the
pipe/socket and display it. I don't think that feature exists right
now though.

Matt
 
G

Gabriel Genellina

Running in a separate process? That isn't possible. Okay, well, it
isn't possible without doing a fair amount of work on your own. You
would probably need to create a handler that writes everything to a
pipe or a socket, and then have your second application read from the
pipe/socket and display it. I don't think that feature exists right
now though.

Yes, it does, it's easy, and it's one of the examples included in the
logging documentation.
http://www.python.org/doc/2.6/libra...and-receiving-logging-events-across-a-network
Writing the wxPython app is left to the OP :)
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top