Skip to content

Instantly share code, notes, and snippets.

@javouhey
Created August 15, 2011 01:49
Show Gist options
  • Save javouhey/1145583 to your computer and use it in GitHub Desktop.
Save javouhey/1145583 to your computer and use it in GitHub Desktop.
Python log handler
class GavinLogHandler(logging.Handler):
""" my experiment """
def emit(self, record):
print "name=" + str(record.name)
if record.exc_info:
print "exc_info=" + str(record.exc_info)
if record.exc_text:
print "exc_text=" + str(record.exc_text)
if not isinstance(record.msg, Exception):
print 'msg=' + record.msg
else:
return
for i in record.args:
print type(i)
print self.format(record)
print 'record.__dict__=>' + str(record.__dict__)
d = record.__dict__
if d:
if d.has_key('c'):
print "received c"
if d.has_key('g'):
print "received g"
class Special(logging.Logger):
""" gavin """
def __init__(self, name, level=logging.CRITICAL):
logging.Logger.__init__(self, name, level)
def fb(self, msg, *args, **kwargs):
self.log(self.level, msg, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment