/** * Returns the string representation of the timestamp based on the default format pattern, microseconds. * * @param usecs * microseconds * @return formatted date/time string based on pattern */ public static String getTimeStamp(long usecs) { long msecs = usecs / 1000L; return getTimeStamp(null, msecs, (usecs - msecs * 1000)); }
/** * {@inheritDoc} * <p> * Returns the string representation of this timestamp in the default timezone. * </p> */ @Override public String toString() { return getTimeStamp(msecs, usecs); }
/** * Returns the string representation of this timestamp in the specified timezone. * * @param tz * timezone * @return formatted date/time string in specified timezone */ public String toString(TimeZone tz) { return getTimeStamp(null, tz, msecs, usecs); }
/** * Returns the string representation of this timestamp based on the specified format pattern in the default * timezone. * * @param pattern * format pattern * @return formatted date/time string based on pattern */ public String toString(String pattern) { return getTimeStamp(pattern, msecs, usecs); }
/** * Returns the string representation of the timestamp based on the given format pattern, milliseconds. * * @param pattern * format pattern * @param usecs * milliseconds * @return formatted date/time string based on pattern */ public static String getTimeStamp(String pattern, long usecs) { long msecs = usecs / 1000L; return getTimeStamp(pattern, msecs, (usecs - msecs * 1000)); }
/** * Returns the string representation of this timestamp based on the specified format pattern in the specified * timezone. * * @param pattern * format pattern * @param tz * timezone * @return formatted date/time string based on pattern */ public String toString(String pattern, TimeZone tz) { return getTimeStamp(pattern, tz, msecs, usecs); }
/** * Returns the string representation of the timestamp based on the default format pattern, milliseconds and * microseconds. * * @param msecs * milliseconds * @param usecs * microseconds * @return formatted date/time string based on pattern */ public static String getTimeStamp(long msecs, long usecs) { return getTimeStamp(null, msecs, usecs); }
/** * Create a default dump sink factory with default dump location. */ public DefaultDumpSinkFactory() { dumpLocation = DEFAULT_DUMP_FOLDER; if (!dumpLocation.endsWith(File.separator)) { dumpLocation += File.separator; } dumpLocation += UsecTimestamp.getTimeStamp("yyyy-MM-dd") + ".dump"; }
/** * Returns the string representation of the timestamp based on the specified format pattern, milliseconds and * microseconds, default timezone. * * @param pattern * format pattern * @param msecs * milliseconds * @param usecs * microseconds * @return formatted date/time string based on pattern */ public static String getTimeStamp(String pattern, long msecs, long usecs) { return getTimeStamp(pattern, TimeZone.getDefault(), msecs, usecs); }
/** * Returns the string representation of the current timestamp, with a given time zone. * * @param tz * format current time based on a given timezone. * @return formatted date/time string based on default pattern and given timezone */ public static String getTimeStamp(TimeZone tz) { return getTimeStamp(null, tz, TimeService.currentTimeMillis(), 0); }
/** * Returns the string representation of the current timestamp. * * @return formatted date/time string based on default pattern */ public static String getTimeStamp() { return getTimeStamp(null, TimeService.currentTimeMillis(), 0); }
/** * Returns the string representation of the current timestamp based on the given format pattern. * * @param pattern * format pattern * @return formatted date/time string based on pattern */ public static String getTimeStamp(String pattern) { return getTimeStamp(pattern, TimeService.currentTimeMillis(), 0); }
@Override public String getCloseStanza(DumpSink sink) { StringBuilder buffer = new StringBuilder(1024); buffer.append("{\n"); Utils.quote("dump.status", buffer).append(": "); Utils.quote("END", buffer).append(END_ATTR); Utils.quote("server.name", buffer).append(": "); Utils.quote(Utils.getLocalHostName(), buffer).append(END_ATTR); Utils.quote("server.address", buffer).append(": "); Utils.quote(Utils.getLocalHostAddress(), buffer).append(END_ATTR); Utils.quote("vm.name", buffer).append(": "); Utils.quote(Utils.getVMName(), buffer).append(END_ATTR); Utils.quote("vm.pid", buffer).append(": ").append(Utils.getVMPID()).append(END_ATTR); Utils.quote("dump.sink", buffer).append(": "); Utils.quote(sink, buffer).append(END_ATTR); Utils.quote("dump.time.string", buffer).append(": "); Utils.quote(UsecTimestamp.getTimeStamp(), buffer).append(END_ATTR); long elapsed_ms = TimeService.currentTimeMillis() - TIME_TABLE.get(); Utils.quote("dump.elapsed.ms", buffer).append(": ").append(elapsed_ms); buffer.append("\n}"); return buffer.toString(); }
@Override public String getOpenStanza(DumpSink sink) { StringBuilder buffer = new StringBuilder(1024); TIME_TABLE.set(TimeService.currentTimeMillis()); buffer.append("{\n"); Utils.quote("dump.status", buffer).append(": "); Utils.quote("START", buffer).append(END_ATTR); Utils.quote("server.name", buffer).append(": "); Utils.quote(Utils.getLocalHostName(), buffer).append(END_ATTR); Utils.quote("server.address", buffer).append(": "); Utils.quote(Utils.getLocalHostAddress(), buffer).append(END_ATTR); Utils.quote("vm.name", buffer).append(": "); Utils.quote(Utils.getVMName(), buffer).append(END_ATTR); Utils.quote("vm.pid", buffer).append(": ").append(Utils.getVMPID()).append(END_ATTR); Utils.quote("dump.sink", buffer).append(": "); Utils.quote(sink, buffer).append(END_ATTR); Utils.quote("dump.time.string", buffer).append(": "); Utils.quote(UsecTimestamp.getTimeStamp(), buffer); buffer.append("\n}"); return buffer.toString(); } }
StringBuilder msg = new StringBuilder(1024); msg.append("{status: '").append(activity.getStatus()).append("'").append(separator); msg.append("time: '").append(UsecTimestamp.getTimeStamp(timeZone)).append("'").append(separator); msg.append("sev: '").append(activity.getSeverity()).append("'").append(separator); msg.append("type: '").append(activity.getType()).append("'").append(separator);
buffer.append(padding); Utils.quote("dump.time.string", buffer).append(": "); Utils.quote(UsecTimestamp.getTimeStamp(dump.getTime(), 0), buffer).append(END_ATTR); buffer.append(padding); Utils.quote("dump.time.stamp", buffer).append(": ").append(dump.getTime()).append(END_ATTR);
@Override public String format(long ttl, Source src, OpLevel level, String msg, Object... args) { String srcName = src != null ? src.getFQName() : DefaultSourceFactory.getInstance().getRootSource().getFQName(); return Utils.format(formatString, UsecTimestamp.getTimeStamp(timeZone), level, Utils.format(msg, args), srcName); }