/** * {@inheritDoc} */ @Override public void error(final String message, final Throwable t) { this.addMessage(message, "[Crit]", t); }
private void addMessage(final String message, final String severity, final Throwable throwable) { Queue<String> queue; synchronized (LogImplWebguiLogging.QUEUES) { // Get the right queue and create it if necessary. queue = LogImplWebguiLogging.QUEUES.get(this.name); if (queue == null) { queue = new ArrayBlockingQueue<String>(MAX_ENTRIES); LogImplWebguiLogging.QUEUES.put(this.name, queue); } } synchronized (queue) { // Is the queue full? if (queue.size() >= MAX_ENTRIES) { this.removeOldestEntryFrom(queue); } final StringBuilder sb = new StringBuilder(255) .append(this.date.format(new java.util.Date())) // this has to be within synchronized .append(": ") .append(severity) .append(' ') .append(message); if (null != throwable) { sb.append('\n'); sb.append(throwable.toString()); } queue.add(sb.toString()); } }
/** * Delivers the log for the given name or creates a new one if it doesn't exist already. * * @param name * The corresponding name. * * @return A logger for the given name. */ public static final Log getLog(final String name) { switch (DETECTED_LOGGER) { // NOPMD (no break needed) case NONE: return new LogImplNone(name); case JDK: return new LogImplJDK14(name); case COMMONS: return new LogImplCommonsLogging(name); case SLF4J: return new LogImplSLF4JLogging(name); case WEBGUI: return new LogImplWebguiLogging(name); case JUNIT: return new LogImplJUnit(name); default: return new LogImplJDK14(name); } }
/** * {@inheritDoc} */ @Override public void error(final String message) { this.addMessage(message, "[Crit]", null); }
/** * {@inheritDoc} */ @Override public void info(final String message, final Throwable t) { this.addMessage(message, "[Info]", t); }
/** * {@inheritDoc} */ @Override public void warn(final String message) { this.addMessage(message, "[Warn]", null); }
/** * {@inheritDoc} */ @Override public void info(final String message) { this.addMessage(message, "[Info]", null); }
/** * {@inheritDoc} */ @Override public void warn(final String message, final Throwable t) { this.addMessage(message, "[Warn]", t); }