@Test public void validateDelegateLoggerReceivesThrowableToStringOnError() { componentLog.error("Hello {}", e); verify(logger, times(1)).error(anyString(), argThat(new MyVarargMatcher())); }
@Override public void error(String msg, Throwable t) { if (!isErrorEnabled()) { return; } msg = "{} " + msg; Object[] os = t == null ? new Object[]{component} : new Object[]{component, t.toString()}; logger.error(msg, os); if (t != null){ logger.error("", t); logRepository.addLogMessage(LogLevel.ERROR, msg, os, t); } else { logRepository.addLogMessage(LogLevel.ERROR, msg, os); } }
SimpleProcessLogger implements ComponentLog { @Override public void error(String msg, Throwable t) { if (!isErrorEnabled()) { return; } msg = "{} " + msg; Object[] os = t == null ? new Object[]{component} : new Object[]{component, t.toString()}; logger.error(msg, os); if (t != null){ logger.error("", t); logRepository.addLogMessage(LogLevel.ERROR, msg, os, t); } else { logRepository.addLogMessage(LogLevel.ERROR, msg, os); } } }
SimpleProcessLogger implements ComponentLog { @Override public void error(String msg, Throwable t) { if (!isErrorEnabled()) { return; } msg = "{} " + msg; Object[] os = t == null ? new Object[]{component} : new Object[]{component, t.toString()}; logger.error(msg, os); if (t != null){ logger.error("", t); logRepository.addLogMessage(LogLevel.ERROR, msg, os, t); } else { logRepository.addLogMessage(LogLevel.ERROR, msg, os); } } SimpleProcessLogger(final String componentId, final Object component); }
SimpleProcessLogger implements ComponentLog { @Override public void error(String msg, Throwable t) { if (!isErrorEnabled()) { return; } msg = "{} " + msg; Object[] os = t == null ? new Object[]{component} : new Object[]{component, t.toString()}; logger.error(msg, os); if (t != null){ logger.error("", t); logRepository.addLogMessage(LogLevel.ERROR, msg, os, t); } else { logRepository.addLogMessage(LogLevel.ERROR, msg, os); } } SimpleProcessLogger(final String componentId, final Object component); @Override void warn(String msg, final Throwable t); @Override void warn(String msg, Object[] os); @Override void warn(String msg, Object[] os, final Throwable t); @Override void warn(String msg); @Override void trace(String msg, Throwable t); @Override void trace(String msg, Object[] os); @Override void trace(String msg); @Override void trace(String msg, Object[] os, Throwable t); @Override boolean isTraceEnabled(); @Override boolean isDebugEnabled(); @Override boolean isInfoEnabled(); @Override boolean isWarnEnabled(); @Override boolean isErrorEnabled(); @Override void info(String msg, Throwable t); @Override void info(String msg, Object[] os); @Override void info(String msg); @Override void info(String msg, Object[] os, Throwable t); @Override String getName(); @Override void error(String msg, Throwable t); @Override void error(String msg, Object[] os); @Override void error(String msg); @Override void error(String msg, Object[] os, Throwable t); @Override void debug(String msg, Throwable t); @Override void debug(String msg, Object[] os); @Override void debug(String msg, Object[] os, Throwable t); @Override void debug(String msg); @Override void log(LogLevel level, String msg, Throwable t); @Override void log(LogLevel level, String msg, Object[] os); @Override void log(LogLevel level, String msg); @Override void log(LogLevel level, String msg, Object[] os, Throwable t); }
SimpleProcessLogger implements ComponentLog { @Override public void error(String msg, Throwable t) { if (!isErrorEnabled()) { return; } msg = "{} " + msg; Object[] os = t == null ? new Object[]{component} : new Object[]{component, t.toString()}; logger.error(msg, os); if (t != null){ logger.error("", t); logRepository.addLogMessage(LogLevel.ERROR, msg, os, t); } else { logRepository.addLogMessage(LogLevel.ERROR, msg, os); } } SimpleProcessLogger(final String componentId, final Object component); @Override void warn(String msg, final Throwable t); @Override void warn(String msg, Object[] os); @Override void warn(String msg, Object[] os, final Throwable t); @Override void warn(String msg); @Override void trace(String msg, Throwable t); @Override void trace(String msg, Object[] os); @Override void trace(String msg); @Override void trace(String msg, Object[] os, Throwable t); @Override boolean isTraceEnabled(); @Override boolean isDebugEnabled(); @Override boolean isInfoEnabled(); @Override boolean isWarnEnabled(); @Override boolean isErrorEnabled(); @Override void info(String msg, Throwable t); @Override void info(String msg, Object[] os); @Override void info(String msg); @Override void info(String msg, Object[] os, Throwable t); @Override String getName(); @Override void error(String msg, Throwable t); @Override void error(String msg, Object[] os); @Override void error(String msg); @Override void error(String msg, Object[] os, Throwable t); @Override void debug(String msg, Throwable t); @Override void debug(String msg, Object[] os); @Override void debug(String msg, Object[] os, Throwable t); @Override void debug(String msg); @Override void log(LogLevel level, String msg, Throwable t); @Override void log(LogLevel level, String msg, Object[] os); @Override void log(LogLevel level, String msg); @Override void log(LogLevel level, String msg, Object[] os, Throwable t);  }