public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
@Override public String doLayout(ILoggingEvent event) { if (!isStarted()) { return CoreConstants.EMPTY_STRING; } StringBuilder sb = new StringBuilder(); long timestamp = event.getTimeStamp(); sb.append(cachingDateFormatter.format(timestamp)); sb.append(" ["); sb.append(event.getThreadName()); sb.append("] "); sb.append(event.getLevel().toString()); sb.append(" "); sb.append(event.getLoggerName()); sb.append(" - "); sb.append(event.getFormattedMessage()); sb.append(CoreConstants.LINE_SEPARATOR); IThrowableProxy tp = event.getThrowableProxy(); if (tp != null) { String stackTrace = tpc.convert(event); sb.append(stackTrace); } return sb.toString(); }
public String convert(Date date) { return cdf.format(date.getTime()); }
public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
private void printStatus(StringBuilder buf, Status s) { String trClass; if (count % 2 == 0) { trClass = "even"; } else { trClass = "odd"; } buf.append(" <tr class=\"").append(trClass).append("\">\r\n"); String dateStr = SDF.format(s.getDate()); buf.append(" <td class=\"date\">").append(dateStr).append("</td>\r\n"); buf.append(" <td class=\"level\">").append(statusLevelAsString(s)) .append("</td>\r\n"); buf.append(" <td>").append(abbreviatedOrigin(s)).append("</td>\r\n"); buf.append(" <td>").append(s.getMessage()).append("</td>\r\n"); buf.append(" </tr>\r\n"); if (s.getThrowable() != null) { printThrowable(buf, s.getThrowable()); } }
public static void buildStr(StringBuilder sb, String indentation, Status s) { String prefix; if (s.hasChildren()) { prefix = indentation + "+ "; } else { prefix = indentation + "|-"; } if (cachingDateFormat != null) { String dateStr = cachingDateFormat.format(s.getDate()); sb.append(dateStr).append(" "); } sb.append(prefix).append(s).append(CoreConstants.LINE_SEPARATOR); if (s.getThrowable() != null) { appendThrowable(sb, s.getThrowable()); } if (s.hasChildren()) { Iterator<Status> ite = s.iterator(); while (ite.hasNext()) { Status child = ite.next(); buildStr(sb, indentation + " ", child); } } }
String val = sdf.format(timeReference);
public String convert(Date date) { return cdf.format(date.getTime()); }
public String convert(Date date) { return cdf.format(date.getTime()); }
public String convert(Date date) { return cdf.format(date.getTime()); }
public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
@Override public String convert(IAccessEvent accessEvent) { long timestamp = accessEvent.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
public String convert(ILoggingEvent le) { long timestamp = le.getTimeStamp(); return cachingDateFormatter.format(timestamp); } }
@Test public void timeZoneIsTakenIntoAccount() throws ParseException { CachingDateFormatter cdf = new CachingDateFormatter(DATE_PATTERN); TimeZone perthTZ = TimeZone.getTimeZone("Australia/Perth"); cdf.setTimeZone(perthTZ); Date march26_2015_0949_UTC = sdf.parse("2015-03-26T09:49"); System.out.print(march26_2015_0949_UTC); String result = cdf.format(march26_2015_0949_UTC.getTime()); // AWST (Perth) is 8 hours ahead of UTC assertEquals("2015-03-26T17:49", result); } }
@Test public void timestamp() throws JoranException, IOException, InterruptedException { String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "timestamp-context.xml"; configure(configFileAsStr); String r = loggerContext.getProperty("testTimestamp"); assertNotNull(r); CachingDateFormatter sdf = new CachingDateFormatter("yyyy-MM"); String expected = sdf.format(System.currentTimeMillis()); assertEquals("expected \"" + expected + "\" but got " + r, expected, r); }
@Test public void basic() throws Exception { loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "unique.xml"); CachingDateFormatter sdf = new CachingDateFormatter("yyyyMMdd'T'HHmm"); String timestamp = sdf.format(System.currentTimeMillis()); sc.assertIsErrorFree(); Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME); root.info("hello"); File file = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "UNIK_" + timestamp + diffAsStr + "log.txt"); assertTrue(file.exists()); } }
@Test public void testDateConverter() { DateConverter converter = new DateConverter(); converter.start(); String result = converter.convert(event); assertEquals(converter.cachingDateFormatter.format(event.getTimeStamp()), result); }