Skip to content

Instantly share code, notes, and snippets.

View Ry4an's full-sized avatar

Ry4an Brase Ry4an

View GitHub Profile
@wolever
wolever / monkypatch_logging.py
Created September 14, 2014 21:21
Monkey patch for logging.LogRecord.getMessage so it will never, ever raise an exception
def monkeypatch_logging_getMessage():
""" Monkey patch logging.LogRecord.getMessage so it will never, ever raise an exception. """
from unstdlib import to_str
from logging import LogRecord
oldGetMessage = LogRecord.getMessage
def getMessage(self):
try:
return oldGetMessage(self)
except Exception as e: