Decorator for logging time for a function.