Skip to content

Instantly share code, notes, and snippets.

@vsajip
Created September 19, 2010 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsajip/586656 to your computer and use it in GitHub Desktop.
Save vsajip/586656 to your computer and use it in GitHub Desktop.
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