[logback-dev] svn commit: r631 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util

noreply.ceki at qos.ch noreply.ceki at qos.ch
Sun Oct 8 18:07:45 CEST 2006


Author: ceki
Date: Sun Oct  8 18:07:45 2006
New Revision: 631

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java

Log:
Added a variant of the print method taking in a Context.

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java	Sun Oct  8 18:07:45 2006
@@ -1,28 +1,44 @@
 /**
- * LOGBack: the reliable, fast and flexible logging library for Java.
- *
+ * Logback: the reliable, fast and flexible logging library for Java.
+ * 
  * Copyright (C) 1999-2006, QOS.ch
- *
- * This library is free software, you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
  */
+
 package ch.qos.logback.core.util;
 
 import java.util.Iterator;
 
+import ch.qos.logback.core.Context;
 import ch.qos.logback.core.status.Status;
 import ch.qos.logback.core.status.StatusManager;
 
 public class StatusPrinter {
 
+  public static void print(Context context) {
+    if (context == null) {
+      throw new IllegalArgumentException("Context argument cannot be null");
+    }
+
+    StatusManager sm = context.getStatusManager();
+    if (sm == null) {
+      System.out.println("WARN: Context named \"" + context.getName()
+          + "\" has no status manager");
+    }
+
+    print(sm);
+  }
+
   public static void print(StatusManager sm) {
-  	
+
     Iterator it = sm.iterator();
-    while(it.hasNext()) {
+    while (it.hasNext()) {
       Status s = (Status) it.next();
       System.out.println(s);
-      if(s.getThrowable() != null) {
+      if (s.getThrowable() != null) {
         s.getThrowable().printStackTrace(System.out);
       }
     }



More information about the logback-dev mailing list