Created
September 19, 2010 10:50
-
-
Save vsajip/586656 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lbprivate import private_library_function | |
def library_function(): | |
private_library_function() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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