Last active
December 18, 2015 14:48
-
-
Save bruth/5799393 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 logging | |
# http://stackoverflow.com/a/1049375/407954 | |
class MockHandler(logging.Handler): | |
def __init__(self, *args, **kwargs): | |
self.reset() | |
logging.Handler.__init__(self, *args, **kwargs) | |
def emit(self, record): | |
self.messages[record.levelname.lower()].append(record.getMessage()) | |
def reset(self): | |
self.messages = { | |
'debug': [], | |
'info': [], | |
'warning': [], | |
'error': [], | |
'critical': [], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment