def trace_dispatch(trace, command, func):
    """
    Returns a wrapper for ``func`` which will record the dispatch in the trace
    log.
    """
    def dispatch(event):
        func(event)
        trace.recordEvent(command, event)

    return dispatch