original_docstring: Redirect sys.stdout to a BruteLogger copying to stdout + logfile
docstring: Redirect sys.stdout to a BruteLogger copying to stdout + logfile
docstring_tokens: Redirect sys . stdout to a BruteLogger copying to stdout + logfile
code: def save_stdout_to_file(fname=time.strftime("%y%m%d_%H%M.log"), path='logs',
                              mode='w', encoding='utf8', also_stderr=False):
          """Redirect sys.stdout to a BruteLogger copying to stdout + logfile"""
          if not os.path.exists(path): os.makedirs(path)
          full_name = os.path.join(path, fname)
          file_desc = open(full_name, mode=mode, encoding=encoding, buffering=1)
          sys.stdout = BruteLogger(sys.stdout, file_desc)
          if also_stderr: sys.stderr = sys.stdout
code_tokens: def save_stdout_to_file ( fname = time . strftime ( "%y%m%d_%H%M.log" ) , path = 'logs' , mode = 'w' , encoding = 'utf8' , also_stderr = False ) : if not os . path . exists ( path ) : os . makedirs ( path ) full_name = os . path . join ( path , fname ) file_desc = open ( full_name , mode = mode , encoding = encoding , buffering = 1 ) sys . stdout = BruteLogger ( sys . stdout , file_desc ) if also_stderr : sys . stderr = sys . stdout
short_docstring: Redirect sys.stdout to a BruteLogger copying to stdout + logfile
short_docstring_tokens: Redirect sys . stdout to a BruteLogger copying to stdout + logfile
comment: """Redirect sys.stdout to a BruteLogger copying to stdout + logfile"""