Last active
October 5, 2018 08:03
-
-
Save misterjoa/0efb35c6d3d5beb865d5c1a89d2e62d3 to your computer and use it in GitHub Desktop.
Very simple python logging handler using print statements
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
| from logging import Handler, getLevelName | |
| import sys | |
| class DumbHandler(Handler): | |
| def __init__(self): | |
| Handler.__init__(self) | |
| def flush(self): | |
| sys.stdout.flush() | |
| def emit(self, record): | |
| print(self.format(record)) | |
| def __repr__(self): | |
| level = getLevelName(self.level) | |
| name = 'print' | |
| if name: | |
| name += ' ' | |
| return '<%s %s(%s)>' % (self.__class__.__name__, name, level) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment