logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1391607 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
Date Fri, 28 Sep 2012 19:18:07 GMT
Author: ggregory
Date: Fri Sep 28 19:18:06 2012
New Revision: 1391607

URL: http://svn.apache.org/viewvc?rev=1391607&view=rev
Log:
Implement toString().

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1391607&r1=1391606&r2=1391607&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java
Fri Sep 28 19:18:06 2012
@@ -342,4 +342,16 @@ public class Logger extends AbstractLogg
             return intLevel >= level.intLevel();
         }
     }
+    
+    /**
+     * Returns a Stirng representation of this instance in the form {@code "name:level[ in
context_name]"}.
+     */
+    public String toString() {
+        final String nameLevel = this.name + ":" + this.getLevel();
+        if (context == null) {
+            return nameLevel;
+        }
+        final String contextName = this.context.getName();
+        return contextName == null ? nameLevel : nameLevel + " in " + contextName;
+    }
 }



Mime
View raw message