@contextlib.contextmanager
def indent_log(num=2):
 _log_state.indentation += num
 try:
  (yield)
 finally:
  _log_state.indentation -= num

@ contextlib . contextmanager def indent_log ( num = 2 ) : _log_state . indentation += num try : ( yield ) finally : _log_state . indentation -= num
a context manager which will cause the log output to be indented for any log messages emitted inside it .