Question on templates and python logging

D

David LePage

Hi -
I have been struggling with this problem for quite some time and was hoping somebody could give me some pointers.

I have a wxPython front end wizard that collects some information and outputs some HTML pages (not hosted by a web server, but viewable locally on the machine running the application).

The problem that i'm trying to solve is taking data collected along the way and outputting this into these HTML pages.

One of the pages is simply collecting debug information about the execution of the program.
All logging is currently being done using the python logging library.

Due to the fact that my HTML files need to be populated in the <body> tags, I wanted to write directly to the proper HTML page based on the logging level message (INFO, DEBUG, etc).

Something like this works nicely if you have a dictionary storing the data:

def template():
return open("html/html.tmpl", 'r').read() % vars

print template("html/Logs.html", { 'body' : "A test body field" })


But in my case, some of the data could be MB in size and I didn't want to read/write that entire load of data before displaying the pages if at all possible.
I was hoping I could tie the logging classes into something like this, where I was leveraging an HTML template, but also taking advantage of the logging library since it works nicely for me today.

Does anybody have any suggestions on how they might approach this problem?

thanks!

DLP
 

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,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top