@Test public void error() throws IOException, InterruptedException { SynchronizingSelfLog.error("test for SynchronizingSelfLog error situation"); SynchronizingSelfLog.flush(); File log = customFileLog("sync.log"); List<String> logs = FileUtils.readLines(log); assertTrue(logs.toString(), logs.get(0).contains("[ERROR]")); assertTrue(logs.toString(), logs.get(0).contains("test for SynchronizingSelfLog error situation")); }
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(); selfAppender.append(sw.toString()); selfAppender.flush(); } catch (Throwable t) { t.printStackTrace(); } }
SynchronizingSelfLog { 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(); selfAppender.append(sw.toString()); selfAppender.flush(); } catch (Throwable t) { t.printStackTrace(); } } }
SynchronizingSelfLog { 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(); selfAppender.append(sw.toString()); selfAppender.flush(); } catch (Throwable t) { t.printStackTrace(); } }  }
SynchronizingSelfLog { 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(); selfAppender.append(sw.toString()); selfAppender.flush(); } 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(); }
SynchronizingSelfLog { 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(); selfAppender.append(sw.toString()); selfAppender.flush(); } 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();  }