def eventlog_sink(app):
    """Return eventlog and sink objects"""
    sink = io.StringIO()
    handler = logging.StreamHandler(sink)
    # Update the EventLogger config with handler
    cfg = Config()
    cfg.EventLogger.handlers = [handler]

    with mock.patch.object(app.config, 'EventLogger', cfg.EventLogger):
        # recreate the eventlog object with our config
        app.init_eventlog()
        # return the sink from the fixture
        yield app.eventlog, sink
    # reset eventlog with original config
    app.init_eventlog()
Return eventlog and sink objects
jupyterhub/tests/test_eventlog.py