code: def stdout_cm(self):
          
          with open(self._get_stdout_log(), 'a+') as fh:
              msg = '### {} ###\n'.format(self._datetime)
              fh.write(msg)
              fh.flush()
  
              yield fh
docs: Redirect the stdout to a log file.