Garth T Kidd wrote: >Strikes me that not much work could let someone keep all of their >existing print statements more or less intact and use the logging >module properly, too: > > import logging > > class LoggingHandle: > def __init__(self, wrappedmethod): > self.wrappedmethod = wrappedmethod > def write(self, msg): > msg = msg.rstrip() > if msg: > self.wrappedmethod(msg.rstrip()) > > logging.basicConfig() > log = logging.getLogger('whatever') > stderr = LoggingHandle(log.error) > stdout = LoggingHandle(log.info) > > print >> stdout, "This is informational." # logged as INFO > print >> stderr, "This is an error." # guess. > >Add some basic infrastructure to logging, and you're done. The >Extremely Brave could even alter sys.stderr and sys.stdout. > > Main purpose of logging module is not redirection, but filtering capability. -- Best regards, Michael Dubner (dubnerm at mindless.com) Brainbench MVP/HTML+JavaScript (http://www.brainbench.com) PS: Sorry for my English
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4