Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
If I run the latter script, noting that I want only WARNING and more severe messages in the log, then test.log is perhaps as expected:
[2010-09-16 09:31] WARNING: lbprivate: Warning
[2010-09-16 09:31] ERROR: lbprivate: Error
[2010-09-16 09:31] CRITICAL: lbprivate: Critical
but I get spurious output on the console:
Keep this line with the next, no gaps wanted
[2010-09-16 09:31] DEBUG: lbprivate: Debug
[2010-09-16 09:31] INFO: lbprivate: Info
[2010-09-16 09:31] NOTICE: lbprivate: Notice
Keep this line with the previous, no gaps wanted
So to my way of thinking, the logbook default is bad. The first thing I think is, "what the heck is lbprivate"?
from lbprivate import private_library_function
def library_function():
private_library_function()
import logbook
logger = logbook.Logger(__name__)
def private_library_function():
logger.debug('Debug')
logger.info('Info')
logger.notice('Notice')
logger.warning('Warning')
logger.error('Error')
logger.critical('Critical')
import logbook
import lbmod
import sys
logger = logbook.Logger(__name__)
handler = logbook.FileHandler('test.log', 'w', level='WARNING', bubble=False)
with handler.applicationbound():
print >> sys.stderr, 'Keep this line with the next, no gaps wanted'
lbmod.library_function()
print >> sys.stderr, 'Keep this line with the previous, no gaps wanted'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment