Helper function which takes a Python logging handler and wraps it.
    Returns a callable taking a single argument, which will be wrapped
    in a log record and passed to the handler's emit() method.

    :param handler: A logging.Handler instance.

    :returns: A callable of one argument, which will emit that
              argument to the appropriate logging destination.

def wrap_log_handler(handler):
    """
    Helper function which takes a Python logging handler and wraps it.
    Returns a callable taking a single argument, which will be wrapped
    in a log record and passed to the handler's emit() method.

    :param handler: A logging.Handler instance.

    :returns: A callable of one argument, which will emit that
              argument to the appropriate logging destination.
    """

    # Set the formatter on the handler to be the SimpleFormatter
    handler.setFormatter(SimpleFormatter())

    # Get file name, line number, and function name for
    # wrap_log_handler()
    obj = wrap_log_handler
    filename = inspect.getsourcefile(obj)
    lineno = inspect.getsourcelines(obj)[1]
    funcname = 'wrap_log_handler'

    @functools.wraps(handler.emit)
    def wrapper(msg):
        # First, generate a LogRecord
        record = logging.LogRecord('bark', logging.INFO, filename, lineno,
                                   msg, (), None, funcname)

        # Now, pass it to the handler's emit method
        handler.emit(record)

    return wrapper