def trap_errors(f):
    ''' A decorator to trap and log exceptions '''
    @wraps(f)
    def wrapper(*args, **kwds):
        with error_trapping(f.__name__):
            return f(*args, **kwds)
    return wrapper
 A decorator to trap and log exceptions 
recipes/Python/531821_Error_logging_context_manager/recipe-531821.py