date time id path level msg
346297
private static function debug_print($file, $level, $format, $data)
    {
        array_shift($data);
        foreach ($data as $k => $v) {
            if (is_string($v)) {
                $data[$k] = str_replace("\n", ' ', $v);
            } elseif ($v instanceof \Exception) {
                $data[$k] = $v->__toString();
            } elseif (!is_numeric($v)) {
                $data[$k] = str_replace("\n", " ", json_encode($v));
            }
        }

        $mtime = microtime(true);
        $time = 1000 * ($mtime - intval($mtime));

        $trace = debug_backtrace();
        $location = $trace[2]['function'];
        for ($n = 2; $n < sizeof($trace); $n++) {
            if (isset($trace[$n]['class'])) {
                $location = $trace[$n]['class'];
                break;
            }
        }

        $id = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : getmypid();

        $msg = sizeof($data) ? vsprintf($format, $data) : $format;
        error_log(sprintf("[%s.%03d %s %s %s] %s\n", date('d.m.Y H:m:s'), $time, $id, $level, $location, $msg), 3, $file);
    }
1296863
function getLetterTime(timeString) {
  var totalSeconds = 0;
  var timeValues = {
    's': 1,
    'm': 1 * 60,
    'h': 1 * 60 * 60,
    'd': 1 * 60 * 60 * 24,
    'w': 1 * 60 * 60 * 24 * 7,
  };
  var timePairs;

  //expand to "1 h 30 m 20 s" and split
  timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim();
  timePairs = timeString.split(' ');

  for (var i = 0; i < timePairs.length; i += 2) {
    totalSeconds += parseInt(timePairs[i], 10) *
      timeValues[timePairs[i + 1] || 's'];
  }
  return totalSeconds;
}
1258419
function (classpath, msg) {
            this._logs[this._nbLogs++] = {
                classpath : classpath,
                msg : msg,
                timestamp : (new Date()).getTime()
            };
        }
86229
def find(path,
         level=None,
         message=None,
         time_lower=None, time_upper=None,
         case_sensitive=False):  # pragma: no cover
    
    if level:
        level = level.upper()  # level name has to be capitalized.

    if not case_sensitive:
        message = message.lower()

    with open(path, "r") as f:
        result = Result(path=path,
                        level=level, message=message,
                        time_lower=time_lower, time_upper=time_upper,
                        case_sensitive=case_sensitive,
                        )

        for line in f:
            try:
                _time, _level, _message = [i.strip() for i in line.split(";")]

                if level:
                    if _level != level:
                        continue

                if time_lower:
                    if _time < time_lower:
                        continue

                if time_upper:
                    if _time > time_upper:
                        continue

                if message:
                    if not case_sensitive:
                        _message = _message.lower()

                    if message not in _message:
                        continue

                result.lines.append(line)
            except Exception as e:
                print(e)

    return result
599343
def get_id(date: datetime.datetime) -> str:
        
        date = date.strftime('%Y%m%d')
        return 'PB-{}-{}-{:03d}'.format(date, 'sip', randint(0, 100))
951164
def what_time_is_it_in(self, message, place):
        """"""
        location = get_location(place)
        if location is not None:
            tz = get_timezone(location.lat, location.long)
            if tz is not None:
                ct = datetime.datetime.now(tz=pytz.timezone(tz))
                self.say("It's %(time)s in %(place)s." % {'time': self.to_natural_day_and_time(ct),
                                                          'place': location.name}, message=message)
            else:
                self.say("I couldn't find timezone for %(place)s." % {'place': location.name}, message=message)
        else:
            self.say("I couldn't find anywhere named %(place)s." % {'place': location.name}, message=message)
715760
private String getLastLoginMessage(Long inacTime) {

        int days = (int)(inacTime.longValue() / (1000 * 60 * 60 * 24));
        if (days == 0) {
            return CmsVaadinUtils.getMessageText(Messages.GUI_USER_INFO_LAST_LOGIN_LESS_A_DAY_0);
        }
        if (days == 1) {
            return CmsVaadinUtils.getMessageText(Messages.GUI_USER_INFO_LAST_LOGIN_YESTERDAY_0);
        }
        return CmsVaadinUtils.getMessageText(Messages.GUI_USER_INFO_LAST_LOGIN_DAYS_AGO_1, new Integer(days));
    }
728137
def mtime(path):
    
    if not os.path.exists(path):
        return -1
    stat = os.stat(path)
    return stat.st_mtime
1149172
def read_dates_by_service_ids(
    path: str
) -> Dict[FrozenSet[str], FrozenSet[datetime.date]]:
    """"""
    feed = load_raw_feed(path)
    return _dates_by_service_ids(feed)
315774
private static Date getSentDate(MimeMessage msg, Date defaultVal) {
        if (msg == null) {
            return defaultVal;
        }
        try {
            Date sentDate = msg.getSentDate();
            if (sentDate == null) {
                return defaultVal;
            } else {
                return sentDate;
            }
        } catch (MessagingException me) {
            return new Date();
        }
    }
619325
def _endmsg(self, rd):
        
        msg = ""
        s = ""
        if rd.hours > 0:
            if rd.hours > 1:
                s = "s"
            msg += colors.bold(str(rd.hours)) + " hour" + s + " "
        s = ""
        if rd.minutes > 0:
            if rd.minutes > 1:
                s = "s"
            msg += colors.bold(str(rd.minutes)) + " minute" + s + " "
        # if rd.seconds > 0:
        #    msg+=str(rd.seconds)
        # else:
        #    msg+="0."
        milliseconds = int(rd.microseconds / 1000)
        if milliseconds > 0:
            msg += colors.bold(str(rd.seconds) + "." + str(milliseconds))
        msg += " seconds"
        return msg
584447
def what_time_is_it(self, message):
        """"""
        now = datetime.datetime.now()
        self.say("It's %s." % self.to_natural_day_and_time(now, with_timezone=True), message=message)
1286607
def rerouteTraveltime(self, personID):
        
        self._connection._beginMessage(
            tc.CMD_SET_PERSON_VARIABLE, tc.CMD_REROUTE_TRAVELTIME, personID, 1 + 4)
        self._connection._string += struct.pack("!Bi", tc.TYPE_COMPOUND, 0)
        self._connection._sendExact()
767561
def mtime(self, fpath=None):
        
        return dtformat(
            datetime.datetime.utcfromtimestamp(
                os.path.getmtime(fpath or self.fpath)))
845898
def _GetTimelineStatEntriesRelDB(api_client_id, file_path, with_history=True):
  """"""
  path_type, components = rdf_objects.ParseCategorizedPath(file_path)

  client_id = str(api_client_id)

  try:
    root_path_info = data_store.REL_DB.ReadPathInfo(client_id, path_type,
                                                    components)
  except db.UnknownPathError:
    return

  path_infos = []
  for path_info in itertools.chain(
      [root_path_info],
      data_store.REL_DB.ListDescendentPathInfos(client_id, path_type,
                                                components),
  ):
    # TODO(user): this is to keep the compatibility with current
    # AFF4 implementation. Check if this check is needed.
    if path_info.directory:
      continue

    categorized_path = rdf_objects.ToCategorizedPath(path_info.path_type,
                                                     path_info.components)
    if with_history:
      path_infos.append(path_info)
    else:
      yield categorized_path, path_info.stat_entry, path_info.hash_entry

  if with_history:
    hist_path_infos = data_store.REL_DB.ReadPathInfosHistories(
        client_id, path_type, [tuple(pi.components) for pi in path_infos])
    for path_info in itertools.chain(*hist_path_infos.itervalues()):
      categorized_path = rdf_objects.ToCategorizedPath(path_info.path_type,
                                                       path_info.components)
      yield categorized_path, path_info.stat_entry, path_info.hash_entry
1005913
function stat(path, callback) {
  if (!callback) return stat.bind(this, path);
  fs.lstat(path, function (err, stat) {
    if (err) return callback(err);
    var ctime = stat.ctime / 1000;
    var cseconds = Math.floor(ctime);
    var mtime = stat.mtime / 1000;
    var mseconds = Math.floor(mtime);
    var mode;
    if (stat.isSymbolicLink()) {
      mode = 0120000;
    }
    else if (stat.mode & 0111) {
      mode = 0100755;
    }
    else {
      mode = 0100644;
    }
    callback(null, {
      ctime: [cseconds, Math.floor((ctime - cseconds) * 1000000000)],
      mtime: [mseconds, Math.floor((mtime - mseconds) * 1000000000)],
      dev: stat.dev,
      ino: stat.ino,
      mode: mode,
      uid: stat.uid,
      gid: stat.gid,
      size: stat.size
    });
  });
}
124904
def cli(obj, ids, query, filters, display, from_date=None):
    """"""
    client = obj['client']
    timezone = obj['timezone']
    if ids:
        query = [('id', x) for x in ids]
    elif query:
        query = [('q', query)]
    else:
        query = build_query(filters)
    if from_date:
        query.append(('from-date', from_date))

    r = client.http.get('/alerts', query, page=1, page_size=1000)

    if obj['output'] == 'json':
        click.echo(json.dumps(r['alerts'], sort_keys=True, indent=4, ensure_ascii=False))
    elif obj['output'] in ['json_lines', 'jsonl', 'ndjson']:
        for alert in r['alerts']:
            click.echo(json.dumps(alert, ensure_ascii=False))
    else:
        alerts = [Alert.parse(a) for a in r['alerts']]
        last_time = r['lastTime']
        auto_refresh = r['autoRefresh']

        if display == 'tabular':
            headers = {'id': 'ID', 'lastReceiveTime': 'LAST RECEIVED', 'severity': 'SEVERITY', 'status': 'STATUS',
                       'duplicateCount': 'DUPL', 'customer': 'CUSTOMER', 'environment': 'ENVIRONMENT', 'service': 'SERVICE',
                       'resource': 'RESOURCE', 'group': 'GROUP', 'event': 'EVENT', 'value': 'VALUE', 'text': 'TEXT'}
            click.echo(tabulate([a.tabular('summary', timezone)
                                 for a in alerts], headers=headers, tablefmt=obj['output']))
        elif display in ['compact', 'details']:
            for alert in reversed(alerts):
                color = COLOR_MAP.get(alert.severity, {'fg': 'white'})
                click.secho('{}|{}|{}|{:5d}|{}|{:<5s}|{:<10s}|{:<18s}|{:12s}|{:16s}|{:12s}'.format(
                    alert.id[0:8],
                    DateTime.localtime(alert.last_receive_time, timezone),
                    alert.severity,
                    alert.duplicate_count,
                    alert.customer or '-',
                    alert.environment,
                    ','.join(alert.service),
                    alert.resource,
                    alert.group,
                    alert.event,
                    alert.value or 'n/a'), fg=color['fg'])
                click.secho('   |{}'.format(alert.text), fg=color['fg'])

                if display == 'details':
                    click.secho('    severity   | {} -> {}'.format(alert.previous_severity,
                                                                   alert.severity), fg=color['fg'])
                    click.secho('    trend      | {}'.format(alert.trend_indication), fg=color['fg'])
                    click.secho('    status     | {}'.format(alert.status), fg=color['fg'])
                    click.secho('    resource   | {}'.format(alert.resource), fg=color['fg'])
                    click.secho('    group      | {}'.format(alert.group), fg=color['fg'])
                    click.secho('    event      | {}'.format(alert.event), fg=color['fg'])
                    click.secho('    value      | {}'.format(alert.value), fg=color['fg'])
                    click.secho('    tags       | {}'.format(' '.join(alert.tags)), fg=color['fg'])

                    for key, value in alert.attributes.items():
                        click.secho('    {} | {}'.format(key.ljust(10), value), fg=color['fg'])

                    latency = alert.receive_time - alert.create_time

                    click.secho('        time created  | {}'.format(
                        DateTime.localtime(alert.create_time, timezone)), fg=color['fg'])
                    click.secho('        time received | {}'.format(
                        DateTime.localtime(alert.receive_time, timezone)), fg=color['fg'])
                    click.secho('        last received | {}'.format(
                        DateTime.localtime(alert.last_receive_time, timezone)), fg=color['fg'])
                    click.secho('        latency       | {}ms'.format((latency.microseconds / 1000)), fg=color['fg'])
                    click.secho('        timeout       | {}s'.format(alert.timeout), fg=color['fg'])

                    click.secho('            alert id     | {}'.format(alert.id), fg=color['fg'])
                    click.secho('            last recv id | {}'.format(alert.last_receive_id), fg=color['fg'])
                    click.secho('            customer     | {}'.format(alert.customer), fg=color['fg'])
                    click.secho('            environment  | {}'.format(alert.environment), fg=color['fg'])
                    click.secho('            service      | {}'.format(','.join(alert.service)), fg=color['fg'])
                    click.secho('            resource     | {}'.format(alert.resource), fg=color['fg'])
                    click.secho('            type         | {}'.format(alert.event_type), fg=color['fg'])
                    click.secho('            repeat       | {}'.format(alert.repeat), fg=color['fg'])
                    click.secho('            origin       | {}'.format(alert.origin), fg=color['fg'])
                    click.secho('            correlate    | {}'.format(','.join(alert.correlate)), fg=color['fg'])

        return auto_refresh, last_time