start logging to the given logfile, with timestamps
179850
def setup_logfile(self, logfile, mode='w'):
        ''''''
        self.logfile = open(logfile, mode=mode)
4661
def logs(awsclient, function_name, start_dt, end_dt=None, tail=False):
    
    log.debug('Getting cloudwatch logs for: %s', function_name)
    log_group_name = '/aws/lambda/%s' % function_name

    current_date = None
    start_ts = datetime_to_timestamp(start_dt)
    if end_dt:
        end_ts = datetime_to_timestamp(end_dt)
    else:
        end_ts = None

    # tail mode
    # we assume that logs can arrive late but not out of order
    # so we hold the timestamp of the last logentry and start the next iteration
    # from there
    while True:
        logentries = filter_log_events(awsclient, log_group_name,
                                       start_ts=start_ts, end_ts=end_ts)
        if logentries:
            for e in logentries:
                actual_date, actual_time = decode_format_timestamp(e['timestamp'])
                if current_date != actual_date:
                    # print the date only when it changed
                    current_date = actual_date
                    log.info(current_date)
                log.info('%s  %s' % (actual_time, e['message'].strip()))
        if tail:
            if logentries:
                start_ts = logentries[-1]['timestamp'] + 1
            time.sleep(2)
            continue
        break
836214
def logToFile(path, level=logging.INFO):
    
    logger = logging.getLogger()
    logger.setLevel(level)
    formatter = logging.Formatter(
        '%(asctime)s %(name)s %(levelname)s %(message)s')
    handler = logging.FileHandler(path)
    handler.setFormatter(formatter)
    logger.addHandler(handler)
62610
def _start_monitoring(self):
        
        
        # Grab all the timestamp info
        before = self._file_timestamp_info(self.path)

        while True:
            gevent.sleep(1)
            after = self._file_timestamp_info(self.path)

            added = [fname for fname in after.keys() if fname not in before.keys()]
            removed = [fname for fname in before.keys() if fname not in after.keys()]
            modified = []

            for fname in before.keys():
                if fname not in removed:
                    if os.path.getmtime(fname) != before.get(fname):
                        modified.append(fname)

            if added: 
                self.on_create(added)
            if removed: 
                self.on_delete(removed)
            if modified: 
                self.on_modify(modified)
    
            before = after
984525
def _write_to_log(self, output):
        """"""
        with open(self.log_file, 'a') as log_file:
            log_file.write('\n')
            log_file.write(output)
            log_file.write('\n')
575263
def write_logfile():
    # type: () -> None
    """"""
    command = os.path.basename(os.path.realpath(os.path.abspath(sys.argv[0])))
    now = datetime.datetime.now().strftime('%Y%m%d-%H%M%S.%f')
    filename = '{}-{}.log'.format(command, now)
    with open(filename, 'w') as logfile:
        if six.PY3:
            logfile.write(_LOGFILE_STREAM.getvalue())
        else:
            logfile.write(_LOGFILE_STREAM.getvalue().decode(  # type: ignore
                errors='replace'))
1140494
def init_logs(args, tool="NanoPlot"):
    """"""
    start_time = dt.fromtimestamp(time()).strftime('%Y%m%d_%H%M')
    logname = os.path.join(args.outdir, args.prefix + tool + "_" + start_time + ".log")
    handlers = [logging.FileHandler(logname)]
    if args.verbose:
        handlers.append(logging.StreamHandler())
    logging.basicConfig(
        format='%(asctime)s %(message)s',
        handlers=handlers,
        level=logging.INFO)
    logging.info('{} {} started with arguments {}'.format(tool, __version__, args))
    logging.info('Python version is: {}'.format(sys.version.replace('\n', ' ')))
    return logname
1219472
def attach_log_stream(self):
        
        if self.has_api_logs:
            self.log_stream = self.attach(stdout=True, stderr=True, stream=True)
371732
def rerunExperimentFromLogfile(logFilename):
    
    callLog = LoggingDecorator.load(logFilename)

    # Assume first one is call to constructor
    exp = L246aNetwork(*callLog[0][1]["args"], **callLog[0][1]["kwargs"])

    # Call subsequent methods, using stored parameters
    for call in callLog[1:]:
      method = getattr(exp, call[0])
      method(*call[1]["args"], **call[1]["kwargs"])

    return exp
777251
def _merge_logfiles(self):
        """"""
        # open files, read first lines, extract first dates
        lines = [next(iter(logfile), None) for logfile in self.args['logfile']]

        # adjust lines by timezone
        for i in range(len(lines)):
            if lines[i] and lines[i].datetime:
                lines[i]._datetime = (lines[i].datetime +
                                      timedelta(hours=self.args['timezone']
                                                [i]))

        while any(lines):
            min_line = min(lines, key=self._datetime_key_for_merge)
            min_idx = lines.index(min_line)

            if self.args['markers'][min_idx]:
                min_line.merge_marker_str = self.args['markers'][min_idx]

            yield min_line

            # update lines array with a new line from the min_idx'th logfile
            lines[min_idx] = next(iter(self.args['logfile'][min_idx]), None)
            if lines[min_idx] and lines[min_idx].datetime:
                lines[min_idx]._datetime = (
                    lines[min_idx].datetime +
                    timedelta(hours=self.args['timezone'][min_idx]))
112927
def log(message, level="info"):
    
    now = time.time()
    entry = {}
    entry['level'] = level
    entry['message'] = message
    entry['timestamp'] = now
    _log_entries.append(entry)
870464
def log(self) :
		""""""
		
		self.logs['epochDuration'].append(self.lastEpochDuration)
		self.logs['avg'].append(self.avg)
		self.logs['runtime'].append(self.runtime)
		self.logs['remtime'].append(self.remtime)
511210
def set_logfile(path, instance):
    """"""

    global logfile
    logfile = os.path.normpath(path) + '/hfos.' + instance + '.log'
724293
private void loadTimestampFile() {
        File timestampFile = new File(testSrcDir, timestampFileName);
        if (timestampFile.exists()) {
            try {
                timestampLog.loadFromXML(FileUtils.openInputStream(timestampFile));
            } catch (IOException e) {
                log.warn("timestamp.load.error", e);
            }
        }
    }
584257
private void startLogScheduler() {
    this.logScheduler.scheduleAtFixedRate(
        new Runnable() {
          @Override
          public void run() {
            CLRBufferedLogHandler.this.logAll();
          }
        }, 0, LOG_SCHEDULE_PERIOD, TimeUnit.SECONDS);
  }
895513
def init_logger(logger_file_path, log_level_name='info'):
    
    log_level = log_level_map.get(log_level_name, logging.INFO)
    logger_file = open(logger_file_path, 'w')
    fmt = '[%(asctime)s] %(levelname)s (%(name)s/%(threadName)s) %(message)s'
    logging.Formatter.converter = time.localtime
    formatter = logging.Formatter(fmt, _time_format)
    handler = logging.StreamHandler(logger_file)
    handler.setFormatter(formatter)

    root_logger = logging.getLogger()
    root_logger.addHandler(handler)
    root_logger.setLevel(log_level)

    # these modules are too verbose
    logging.getLogger('matplotlib').setLevel(log_level)

    sys.stdout = _LoggerFileWrapper(logger_file)
1223704
def log(self, *lst):
      
      self.print2file(self.logfile, self.debug, True, *lst)
      if 'Error' in '\n'.join([str(x) for x in lst]):
         self.caught_error = '\n'.join([str(x) for x in lst])