[LOGBack-dev] svn commit: r310 - logback/classic/trunk/src/main/java/ch/qos/logback/classic/util

noreply.seb at qos.ch noreply.seb at qos.ch
Tue Jul 25 18:37:46 CEST 2006


Author: seb
Date: Tue Jul 25 18:37:46 2006
New Revision: 310

Added:
   logback/classic/trunk/src/main/java/ch/qos/logback/classic/util/
   logback/classic/trunk/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
Log:
initial commit

Added: logback/classic/trunk/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java	Tue Jul 25 18:37:46 2006
@@ -0,0 +1,48 @@
+package ch.qos.logback.classic.util;
+
+import java.util.Iterator;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.status.StatusManager;
+
+public class LoggerStatusPrinter {
+	
+	public static void print(StatusManager sm) {
+		if (sm.getCount() == 0) {
+			System.out.println("This status manager contains no errors.");
+			return;
+		}
+		Iterator it = sm.iterator();
+		while (it.hasNext()) {
+			Status s = (Status) it.next();
+			System.out.println(s);
+			if (s.getThrowable() != null) {
+				s.getThrowable().printStackTrace(System.out);
+			}
+		}
+	}
+	
+	public static void printDefaultContext() {
+		Logger logger = (Logger)LoggerFactory.getLogger(LoggerStatusPrinter.class);
+		LoggerContext lc = logger.getLoggerContext();
+		StatusManager sm = lc.getStatusManager();
+		
+		if (sm.getCount() == 0) {
+			System.out.println("This status manager contains no errors.");
+			return;
+		}
+		Iterator it = sm.iterator();
+		while (it.hasNext()) {
+			Status s = (Status) it.next();
+			System.out.println(s);
+			if (s.getThrowable() != null) {
+				s.getThrowable().printStackTrace(System.out);
+			}
+		}
+	}
+	
+}



More information about the logback-dev mailing list