I have a simple custom filter that simply change the log level of an error to a warning. The code is
import logging
LOG = logging.getLogger(__name__)
class MyErrorFilter(logging.Filter):
def filter(self, record):
if record.levelname == 'ERROR':
print 'get record', str(record), record.levelname, record.levelno
LOG.warn('check something')
record.levelname = 'WARNING'
record.levelno = logging.WARNING
return 1
The filter worked well except that the LOG.warn(...) inside my filter did not. I could see the printed message and see the changed log level except the warning message check something. Is this an expected behavior or i made mistakes here? Thanks!