Skip to content

Instantly share code, notes, and snippets.

@andymckay
Created November 5, 2011 00:02
Show Gist options
  • Save andymckay/1340836 to your computer and use it in GitHub Desktop.
Save andymckay/1340836 to your computer and use it in GitHub Desktop.
class ULogger(logging.handlers.SysLogHandler):
def emit(self, record):
msg = self.format(record) + '\000'
prio = '<%d>' % self.encodePriority(self.facility,
self.mapPriority(record.levelname))
if type(msg) is unicode:
msg = msg.encode('utf-8')
#if codecs:
# msg = codecs.BOM_UTF8 + msg
msg = prio + msg
print msg, type(msg)
self.socket.sendto(msg, self.address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment