def test_custom_handling(activation_strategy, logger):
    class MyTestHandler(logbook.TestHandler):
        def handle(self, record):
            if record.extra.get('flag') != 'testing':
                return False
            return logbook.TestHandler.handle(self, record)

    # Check metaclass (== cls.__class__)
    assert logbook.Handler.__class__ == logbook.handlers._HandlerType

    class MyLogger(logbook.Logger):
        def process_record(self, record):
            logbook.Logger.process_record(self, record)
            record.extra['flag'] = 'testing'

    log = MyLogger()
    handler = MyTestHandler()
    with capturing_stderr_context() as captured:
        with activation_strategy(handler):
            log.warn('From my logger')
            logger.warn('From another logger')
        assert handler.has_warning('From my logger')
        assert 'From another logger' in captured.getvalue()
dataset/ETHPy150Open getlogbook/logbook/tests/test_handlers.py/test_custom_handling/original