Re: Proposal: Logging system rewrite
Steven Armstrong <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
On 04/04/05 02:58, will guaraldi wrote: > On Fri, 1 Apr 2005, Steven Armstrong wrote: >> >> As everybody seems to be +1 on this, what do you think about the above >> problem? >> >> What I currently do is the following: >> >> I've created two functions in tools, namely: >> >> tools.py ---------- >> >> _config = None >> def initialize(conf): >> global _config >> _config = conf >> >> def cleanup(): >> "close logfiles and do other cleanup stuff" >> >> ------------------- >> >> I then call tools.initialize(config) from Pyblosxom.initialize. >> tools.cleanup() is called from a new method I've created, >> Pyblosxom.cleanup. Pyblosxom.cleanup is called at the end of the >> Pyblosxom.run* methods. >> >> >> It seems to work nicely. >> Any other/better ideas how to solve this? > > We can't store stuff on the module level without explicitly associating it > with a request. > Hmm ... I don't think that's a problem in this case. All we need from the config dict are log_file and log_level which are static anyway. I would have just imported config.py directly if there were a way to figure out where it is. > What would happen if we took logging out of the tools module and made it > part of the Request object? > We could of course give the request object a util method to get a logger instance. Although I think it would be handy to have the possibility to get a logger anywhere. I think of the logging stuff as living in the application scope not in the request scope. (offcourse for cgi that's +- the same %-)) Steven ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click