@Test public void testErrorLog() throws Exception { SelfLog.error("Error info"); SelfLog.error("Error", new RuntimeException("error")); TestUtil.waitForAsyncLog(); List<String> logs = FileUtils.readLines(tracerSelfLog()); assertTrue(!logs.isEmpty()); }
public static void error(String log, Throwable e) { try { String timestamp = Timestamp.currentTime(); StringWriter sw = new StringWriter(4096); PrintWriter pw = new PrintWriter(sw, false); pw.append(timestamp).append(ERROR_PREFIX).append(log).append(StringUtils.NEWLINE); e.printStackTrace(pw); pw.println(); pw.flush(); selfLogAppenderManager.append(sw.toString()); } catch (Throwable t) { t.printStackTrace(); } }
SelfLog { public static void error(String log, Throwable e) { try { String timestamp = Timestamp.currentTime(); StringWriter sw = new StringWriter(4096); PrintWriter pw = new PrintWriter(sw, false); pw.append(timestamp).append(ERROR_PREFIX).append(log).append(StringUtils.NEWLINE); e.printStackTrace(pw); pw.println(); pw.flush(); selfLogAppenderManager.append(sw.toString()); } catch (Throwable t) { t.printStackTrace(); } } }
SelfLog { public static void error(String log, Throwable e) { try { String timestamp = Timestamp.currentTime(); StringWriter sw = new StringWriter(4096); PrintWriter pw = new PrintWriter(sw, false); pw.append(timestamp).append(ERROR_PREFIX).append(log).append(StringUtils.NEWLINE); e.printStackTrace(pw); pw.println(); pw.flush(); selfLogAppenderManager.append(sw.toString()); } catch (Throwable t) { t.printStackTrace(); } }  }
SelfLog { public static void error(String log, Throwable e) { try { String timestamp = Timestamp.currentTime(); StringWriter sw = new StringWriter(4096); PrintWriter pw = new PrintWriter(sw, false); pw.append(timestamp).append(ERROR_PREFIX).append(log).append(StringUtils.NEWLINE); e.printStackTrace(pw); pw.println(); pw.flush(); selfLogAppenderManager.append(sw.toString()); } catch (Throwable t) { t.printStackTrace(); } }  static void error(String log, Throwable e); static void errorWithTraceId(String log, Throwable e); static void error(String log); static void errorWithTraceId(String log, String traceId); static void errorWithTraceId(String log); static void warn(String log); static void info(String log); static void infoWithTraceId(String log); static void flush(); }
SelfLog { public static void error(String log, Throwable e) { try { String timestamp = Timestamp.currentTime(); StringWriter sw = new StringWriter(4096); PrintWriter pw = new PrintWriter(sw, false); pw.append(timestamp).append(ERROR_PREFIX).append(log).append(StringUtils.NEWLINE); e.printStackTrace(pw); pw.println(); pw.flush(); selfLogAppenderManager.append(sw.toString()); } catch (Throwable t) { t.printStackTrace(); } }  static void error(String log, Throwable e); static void errorWithTraceId(String log, Throwable e); static void error(String log); static void errorWithTraceId(String log, String traceId); static void errorWithTraceId(String log); static void warn(String log); static void info(String log); static void infoWithTraceId(String log); static void flush();  }