Codebase list logbook / 788218b3-b7bb-49d1-81ba-4e959ad6885d/main benchmark / bench_logging_noop_filter.py
788218b3-b7bb-49d1-81ba-4e959ad6885d/main

Tree @788218b3-b7bb-49d1-81ba-4e959ad6885d/main (Download .tar.gz)

bench_logging_noop_filter.py @788218b3-b7bb-49d1-81ba-4e959ad6885d/mainraw · history · blame

"""Tests with a filter disabling a handler for comparsion in logging"""
from logging import getLogger, StreamHandler, Filter
from cStringIO import StringIO


log = getLogger('Testlogger')


class DisableFilter(Filter):
    def filter(self, record):
        return False


def run():
    out = StringIO()
    handler = StreamHandler(out)
    handler.addFilter(DisableFilter())
    log.addHandler(handler)
    for x in xrange(500):
        log.warning('this is not handled')