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;

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
			Date date = log.getDate();
			String message = log.getMessage();

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

			StringBuilder buf = new StringBuilder(32);

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

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

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

		}

	}

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

}

@@ -114,20 +114,71 @@
 va.util.
-Date
+ArrayList;%0Aimport java.util.Date;%0Aimport java.util.List
 ;%0A%0Aimpor
@@ -247,16 +247,51 @@
 tWriter;
+%0Aimport org.gmagnotta.log.LogLevel;
 %0A%0Apublic
@@ -445,29 +445,36 @@
 private 
+List%3C
 String
+%3E
  marker
+s
 ;%0A%09priva
@@ -585,21 +585,36 @@
 at, 
+toListString(
 marker)
+)
 ;%0A%0A%09%7D%0A
+%09
 %0A%09pu
@@ -655,40 +655,154 @@
 ter(
+List%3C
 String
- dateFormat, String
+%3E markers) %7B%0A%0A%09%09this(defaultDateFormat, markers);%0A%0A%09%7D%0A%0A%09public MarkerAwareConsoleLogEventWriter(String dateFormat, List%3CString%3E
  marker
+s
 ) %7B%0A
@@ -847,16 +847,17 @@
 s.marker
+s
  = marke
@@ -857,16 +857,17 @@
 = marker
+s
 ;%0A%09%7D%0A%0A%09@
@@ -934,37 +934,96 @@
 if (
-log.getMarker().equals(marker
+markers.contains(log.getMarker()) &&%0A%09%09%09%09log.getLogLevel().isHigherOrEqual(LogLevel.INFO
 )) %7B
@@ -1502,12 +1502,167 @@
 TO DO%0A%09%7D
+%0A%09%0A%09private static List%3CString%3E toListString(String string) %7B%0A%09%09%0A%09%09List%3CString%3E list = new ArrayList%3CString%3E();%0A%09%09list.add(string);%0A%09%09%0A%09%09return list;%0A%09%09%0A%09%7D
 %0A%0A%7D%0A

allow to manage multiple markers and log only if level is >= INFO