[slf4j-dev] svn commit: r795 - slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers

ceki at slf4j.org ceki at slf4j.org
Sat Apr 21 22:35:19 CEST 2007


Author: ceki
Date: Sat Apr 21 22:35:18 2007
New Revision: 795

Modified:
   slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java

Log:
better toString implementation

Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java	(original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java	Sat Apr 21 22:35:18 2007
@@ -138,8 +138,32 @@
         }
       }     
     }
-    
     return false;
   }
 
+  private static String OPEN = "[ ";
+  private static String CLOSE = " ]";
+  private static String SEP = ", ";
+
+  public String toString() {
+      
+    if (!this.hasChildren()) {
+      return this.getName();
+    }
+    
+    Iterator it = this.iterator();
+    Marker child;
+    StringBuffer sb = new StringBuffer(this.getName());
+    sb.append(' ').append(OPEN);
+    while(it.hasNext()) {
+      child = (Marker)it.next();
+      sb.append(child.getName());
+      if (it.hasNext()) {
+        sb.append(SEP);
+      }
+    }
+    sb.append(CLOSE);
+      
+    return sb.toString();  
+  }
 }



More information about the slf4j-dev mailing list