On Sat, Dec 11, 2010 at 3:06 PM, Nick Coghlan <ncoghlan at gmail.com> wrote: > However, the confusion that this setup will engender is that > encountered by Bill: by default, info() messages are silenced rather > than displayed on stdout. > > Notice that even the recommended "basicConfig" approach to resolving > this is subtly flawed, since your choices are to either display info > messages on stderr (by specifying just a level argument) or to > redirect warning() et al to stdout instead of stderr (by also > specifying a stream argument). The "correct" answer (info and below to > stdout, warning and above to stderr) is actually quite tricky to set > up, since handlers have no innate concept of a "maximum level", so you > have to provide a filter function (more on that below [1]). I need to correct this comment, since it's wrong and basicConfig(level=logging.INFO) actually does the right thing. As Glenn mentioned later in the thread, the output of logging.info and logging.debug messages is *distinct* from an application's normal operational output that is emitted on stdout. So making it easy to emit such messages on stderr is the right thing to do - it's OK that it requires a bit of additional set up to get them onto stdout instead (since they really don't belong there most of the time). I know my own rule of thumb is going to be updated along the lines of "Am I writing to sys.stderr, or guarding output with a verbosity flag? Then perhaps I should be using the logging module rather than print statements". Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
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