import functools
import time


def log_with_timepoints(record_attr):
    """Returns a decorator that logs entry and return times."""
    def log_with_timepoints_decorator(instance_method):
        """Append return value and entry and return times to attribute."""
        @functools.wraps(instance_method)
        def wrapper(self, *args, **kwargs):
            entry_abs = time.time()
            entry_clock = time.perf_counter()
            output = instance_method(self, *args, **kwargs)
            exit_clock = time.perf_counter()
            log = {'output': output, 'enter_abs': entry_abs,
                   'enter_clock': entry_clock, 'exit_clock': exit_clock}
            getattr(self, record_attr).append(log)
            return output
        return wrapper
    return log_with_timepoints_decorator