Do the real job of writing log to file.
483411
private void doPrintln(long timeMillis, int logLevel, String tag, String msg) {
    String lastFileName = writer.getLastFileName();
    if (lastFileName == null || fileNameGenerator.isFileNameChangeable()) {
      String newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis());
      if (newFileName == null || newFileName.trim().length() == 0) {
        throw new IllegalArgumentException("File name should not be empty.");
      }
      if (!newFileName.equals(lastFileName)) {
        if (writer.isOpened()) {
          writer.close();
        }
        cleanLogFilesIfNecessary();
        if (!writer.open(newFileName)) {
          return;
        }
        lastFileName = newFileName;
      }
    }

    File lastFile = writer.getFile();
    if (backupStrategy.shouldBackup(lastFile)) {
      // Backup the log file, and create a new log file.
      writer.close();
      File backupFile = new File(folderPath, lastFileName + ".bak");
      if (backupFile.exists()) {
        backupFile.delete();
      }
      lastFile.renameTo(backupFile);
      if (!writer.open(lastFileName)) {
        return;
      }
    }
    String flattenedLog = flattener.flatten(timeMillis, logLevel, tag, msg).toString();
    writer.appendLog(flattenedLog);
  }
846024
protected void writeLogging(Definition def, Writer out, int indent, String level, String content, String... params)
         throws IOException
   {
      writeIndent(out, indent);
      if (def.isSupportJbossLogging())
      {
         out.write("log.trace");
         int size = params.length;
         if (size > 0)
            out.write("f");
         out.write("(\"" + content + "(");
         for (int i = 0; i < size; i++)
         {
            out.write("%s");
            if (i < size - 1)
               out.write(", ");
         }
         out.write(")\"");
         for (int i = 0; i < size; i++)
         {
            out.write(", ");
            out.write(params[i]);
         }
         out.write(");");
      }
      else
      {
         out.write("log.finest(\"" + content + "()\");");
      }
      writeEol(out);
   }
303061
def log_to_file(logdir, mode='a', delete=False, clearmem=True):
    
    logger = FileLogger(logdir, mode, delete, clearmem)
    _loggers.append(logger)
    return log_to(logger)
454476
def _write_log(self, log_type, log_time, message):
        
        timestamp = datetime.datetime.now().strftime(" %Y-%m-%d %H:%M:%S")
        log_entry = "[{}{}] {}".format(log_type, timestamp if log_time else "", message)
        if self._logger and callable(getattr(self._logger, self._logger_methods[log_type], None)):
            # Check for log handler (sends message only if _logger_no_prefix is True)
            getattr(
                self._logger,
                self._logger_methods[log_type],
                None
                )(message if self._logger_no_prefix else log_entry)
        elif self._log_file:
            # Otherwise write to file, if a file has been specified
            with open(self._log_file, 'a') as logfile:
                try:
                    logfile.write(unicode(log_entry + "\n"))
                except NameError: # `unicode` only works in Python 2
                    logfile.write(log_entry + "\n")
        else:
            # Otherwise, print to STDOUT
            print(log_entry)
173043
static void log(ArrayList<PrintWriter> writers, RecordTypes recordType, 
                  Keys[] keys, String[] values) {
    StringBuffer buf = new StringBuffer(recordType.name()); 
    buf.append(DELIMITER); 
    for(int i =0; i< keys.length; i++){
      buf.append(keys[i]);
      buf.append("=\"");
      values[i] = escapeString(values[i]);
      buf.append(values[i]);
      buf.append("\"");
      buf.append(DELIMITER); 
    }
    buf.append(LINE_DELIMITER_CHAR);
    
    for (PrintWriter out : writers) {
      LogTask task = new LogTask(out, buf.toString());
      fileManager.addWriteTask(task);
    }
  }
935190
def log_to_file(filename, level=DEBUG):
    """"""
    l = logging.getLogger("paramiko")
    if len(l.handlers) > 0:
        return
    l.setLevel(level)
    f = open(filename, 'w')
    lh = logging.StreamHandler(f)
    lh.setFormatter(logging.Formatter('%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d %(name)s: %(message)s',
                                      '%Y%m%d-%H:%M:%S'))
    l.addHandler(lh)
1066890
def setupLogFile(self):
		""""""
		self.logWrite("\n###############################################")
		self.logWrite("calcpkg.py log from " + str(datetime.datetime.now()))
		self.changeLogging(True)
1033827
def log(self, level, *args, **kwargs):
        """"""
        return self._log_kw(level, args, kwargs)
338165
def write_log(title, message=''):
    """"""

    sys.stderr.write(''.join([
        title.center(40).center(60, '-'), '\n', message
    ]))
448031
def log_to_file(filename, level=DEBUG):
    """"""
    logger = logging.getLogger("paramiko")
    if len(logger.handlers) > 0:
        return
    logger.setLevel(level)
    f = open(filename, "a")
    handler = logging.StreamHandler(f)
    frm = "%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d"
    frm += " %(name)s: %(message)s"
    handler.setFormatter(logging.Formatter(frm, "%Y%m%d-%H:%M:%S"))
    logger.addHandler(handler)
81684
def dump_logs(job_queue='run_reach_queue', job_status='RUNNING'):
    """"""
    jobs = get_jobs(job_queue, job_status)
    for job in jobs:
        get_job_log(job, write_file=True)
929592
def dump_to_log(self, logger):
        """"""
        logger.error("Execution ended in %s for cmd %s", self._retcode, self._cmd)
        for line in self._collected_stdout:
            logger.error(STDOUT_LOG_PREFIX + line)
1332450
def write(self, log, rotate=False):
        """"""
        # Get path for logfile
        if rotate:
            timestamp = time.strftime('-%Y%m%d-%H%M')
            logPath = os.path.join(self.log_dir, 'queue{}.log'.format(timestamp))
        else:
            logPath = os.path.join(self.log_dir, 'queue.log')

        # Remove existing Log
        if os.path.exists(logPath):
            os.remove(logPath)

        log_file = open(logPath, 'w')
        log_file.write('Pueue log for executed Commands: \n \n')

        # Format, color and write log
        for key, logentry in log.items():
            if logentry.get('returncode') is not None:
                try:
                    # Get returncode color:
                    returncode = logentry['returncode']
                    if returncode == 0:
                        returncode = Color('{autogreen}' + '{}'.format(returncode) + '{/autogreen}')
                    else:
                        returncode = Color('{autored}' + '{}'.format(returncode) + '{/autored}')

                    # Write command id with returncode and actual command
                    log_file.write(
                        Color('{autoyellow}' + 'Command #{} '.format(key) + '{/autoyellow}') +
                        'exited with returncode {}: \n'.format(returncode) +
                        '"{}" \n'.format(logentry['command'])
                    )
                    # Write path
                    log_file.write('Path: {} \n'.format(logentry['path']))
                    # Write times
                    log_file.write('Start: {}, End: {} \n'
                                   .format(logentry['start'], logentry['end']))

                    # Write STDERR
                    if logentry['stderr']:
                        log_file.write(Color('{autored}Stderr output: {/autored}\n    ') + logentry['stderr'])

                    # Write STDOUT
                    if len(logentry['stdout']) > 0:
                        log_file.write(Color('{autogreen}Stdout output: {/autogreen}\n    ') + logentry['stdout'])

                    log_file.write('\n')
                except Exception as a:
                    print('Failed while writing to log file. Wrong file permissions?')
                    print('Exception: {}'.format(str(a)))

        log_file.close()
1007097
function writeLogs(test, dirName) {
  var logs =
    test.fullTitle() +
    '\n' +
    test.file +
    '\nStart: ' +
    test.start +
    '\nEnd: ' +
    test.end +
    '\nElapsed: ' +
    test.duration +
    '\nStatus: ' +
    test.state;
  if (test.state === 'fail') {
    logs += '\nError: ' + test.err.stack;
  }
  mkdirp.sync(testDir(test, dirName));
  fs.writeFileSync(testURL(test, dirName), logs);
  test.url = testURL(test, dirName);
}
1191406
def save(callLog, logFilename):
    
    with open(logFilename, "wb") as outp:
      cPickle.dump(callLog, outp)
570138
def log(self, msg, error=False):
        """"""
        output = self.stdout
        if error:
            output = self.stderr

        output.write(msg)
        output.write('\n')
1002642
def write(self, log_file, msg):
        
        try:
            with open(log_file, 'a') as LogFile:
                LogFile.write(msg + os.linesep)
        except:
            raise Exception('Error Configuring PyLogger.TextStorage Class.')

        return os.path.isfile(log_file)