package org.gmagnotta.log.impl.system;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.gmagnotta.log.LogEvent;
import org.gmagnotta.log.LogEventWriter;
import org.gmagnotta.log.LogLevel;

public class MarkerAwareConsoleLogEventWriter implements LogEventWriter {

	private static final String defaultDateFormat = "dd/MM/yyyy HH:mm:ss.SSS";

	private String marker;
	private String dateFormat;

	public MarkerAwareConsoleLogEventWriter(String marker) {

		this(defaultDateFormat, marker);

	}

	public MarkerAwareConsoleLogEventWriter(String dateFormat, String marker) {

		this.dateFormat = dateFormat;
		this.marker = marker;
	}

	@Override
	public synchronized void write(LogEvent log) {

		if (log.getMarker().equals(marker)) {

			// Get log detail
			LogLevel logLevel = log.getLogLevel();
			String sourceClass = log.getSourceClass();
			Date date = log.getDate();
			String threadName = log.getThreadName();
			String message = log.getMessage();
			Throwable throwable = log.getThrowable();

			// Create date format
			DateFormat dateFormatter = new SimpleDateFormat(dateFormat);

			StringBuilder buf = new StringBuilder(32);

			// Append date
			buf.append(dateFormatter.format(date));
			buf.append(' ');

			// Append Thread name
			buf.append(threadName);
			buf.append(' ');

			// Append Level in brackets
			buf.append('[');
			buf.append(logLevel.toString());
			buf.append(']');
			buf.append(' ');

			// Append name
			buf.append(sourceClass);
			buf.append(' ');

			// Append message
			buf.append(message);
			buf.append(' ');

			System.out.println(buf.toString());

			// Check if throwable is not null
			if (throwable != null) {

				// Log throwable
				throwable.printStackTrace();

			}

		}

	}

	@Override
	public void stop() throws InterruptedException {
		// NOTHING TO DO
	}

}

@@ -804,969 +804,397 @@
 %0A%09%09%09
-LogLevel logLevel = log.getLogLevel();%0A%09%09%09String sourceClass = log.getSourceClass();%0A%09%09%09Date date = log.getDate();%0A%09%09%09String threadName = log.getThreadName();%0A%09%09%09String message = log.getMessage();%0A%09%09%09Throwable throwable = log.getThrowable();%0A%0A%09%09%09// Create date format%0A%09%09%09DateFormat dateFormatter = new SimpleDateFormat(dateFormat);%0A%0A%09%09%09StringBuilder buf = new StringBuilder(32);%0A%0A%09%09%09// Append date%0A%09%09%09buf.append(dateFormatter.format(date));%0A%09%09%09buf.append(' ');%0A%0A%09%09%09// Append Thread name%0A%09%09%09buf.append(threadName);%0A%09%09%09buf.append(' ');%0A%0A%09%09%09// Append Level in brackets%0A%09%09%09buf.append('%5B');%0A%09%09%09buf.append(logLevel.toString());%0A%09%09%09buf.append('%5D');%0A%09%09%09buf.append(' ');%0A%0A%09%09%09// Append name%0A%09%09%09buf.append(sourceClass);%0A%09%09%09buf.append(' ');%0A%0A%09%09%09// Append message%0A%09%09%09buf.append(message);%0A%09%09%09buf.append(' ');%0A%0A%09%09%09System.out.println(buf.toString());%0A%0A%09%09%09// Check if throwable is not null%0A%09%09%09if (throwable != null) %7B%0A%0A%09%09%09%09// Log throwable%0A%09%09%09%09throwable.printStackTrace();%0A%0A%09%09%09%7D
+Date date = log.getDate();%0A%09%09%09String message = log.getMessage();%0A%0A%09%09%09// Create date format%0A%09%09%09DateFormat dateFormatter = new SimpleDateFormat(dateFormat);%0A%0A%09%09%09StringBuilder buf = new StringBuilder(32);%0A%0A%09%09%09// Append date%0A%09%09%09buf.append(dateFormatter.format(date));%0A%09%09%09buf.append(' ');%0A%0A%09%09%09// Append message%0A%09%09%09buf.append(message);%0A%09%09%09buf.append(' ');%0A%0A%09%09%09System.out.println(buf.toString());
 %0A%0A%09%09

make console logger less verbose