code: def write_to_logfile(out, err, logfile, samplelog=None, sampleerr=None, analysislog=None, analysiserr=None):
      
      # Run log
      with open(logfile + '_out.txt', 'a+') as outfile:
          outfile.write(out + '\n')
      with open(logfile + '_err.txt', 'a+') as outfile:
          outfile.write(err + '\n')
      # Sample log
      if samplelog:
          with open(samplelog, 'a+') as outfile:
              outfile.write(out + '\n')
          with open(sampleerr, 'a+') as outfile:
              outfile.write(err + '\n')
      # Analysis log
      if analysislog:
          with open(analysislog, 'a+') as outfile:
              outfile.write(out + '\n')
          with open(analysiserr, 'a+') as outfile:
              outfile.write(err + '\n')
docs: Writes out and err (both should be strings) to logfile.