/** {@inheritDoc} */ @Override public void format(final LogEvent event, final StringBuilder toAppendTo) { final Marker marker = event.getMarker(); if (marker != null) { toAppendTo.append(marker.getName()); } }
/** * Logs a format string message with the given importance. Message will be prefixed with * [TerrainControl], so don't do that yourself. * * <p> * * @param level The severity of the message * @param message The messages to log formatted similar to Logger.log() with the same args. * @param params The parameters belonging to {0...} in the message string */ public void log(Marker level, String message, Object... params) { String levelName = level.getName(); StringBuilder sb = new StringBuilder(50) .append('[') .append(PLUGIN_NAME) .append("] [") .append( levelName.substring( levelName.lastIndexOf('.') + 1)) // >> only get the basic name not the FQN .append("] ") .append(message); if (LogMarker.compare(logLevel, level) >= 0) { // >> Only log messages that we want to see... // >> Log Fatal, Error, and Warn as what they are without Markers. if (LogMarker.compare(LogMarker.FATAL, level) == 0) { baseLogger.fatal(sb.toString(), params); } else if (LogMarker.compare(LogMarker.ERROR, level) == 0) { baseLogger.error(sb.toString(), params); } else if (LogMarker.compare(LogMarker.WARN, level) == 0) { baseLogger.warn(sb.toString(), params); } else { // >> Otherwise log the message as info and tag it with a marker baseLogger.info(level, sb.toString(), params); } } }