Make (log|print)_durations() work as context managers