You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2012/12/07 20:13:39 UTC

svn commit: r1418445 - /logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java

Author: ggregory
Date: Fri Dec  7 19:13:39 2012
New Revision: 1418445

URL: http://svn.apache.org/viewvc?rev=1418445&view=rev
Log:
[LOG4J2-133] Allow custom message creation via a message factory. Allow null to be passed in for the message factory, which maps to the default factory.

Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java?rev=1418445&r1=1418444&r2=1418445&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java (original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java Fri Dec  7 19:13:39 2012
@@ -74,7 +74,7 @@ public abstract class AbstractLogger imp
      */
     public AbstractLogger() {
         this.name = getClass().getName();
-        this.messageFactory = new ParameterizedMessageFactory();
+        this.messageFactory = createDefaultMessageFactory();
     }
 
     /**
@@ -84,17 +84,22 @@ public abstract class AbstractLogger imp
      */
     public AbstractLogger(String name) {
         this.name = name;
-        this.messageFactory = new ParameterizedMessageFactory();
+        this.messageFactory = createDefaultMessageFactory();
     }
 
     /**
      * Creates a new named logger.
      *
      * @param name the logger name
+     * @param messageFactory the message factory, if null then use the default message factory.
      */
     public AbstractLogger(String name, MessageFactory messageFactory) {
         this.name = name;
-        this.messageFactory = messageFactory;
+        this.messageFactory = messageFactory == null ? createDefaultMessageFactory() : messageFactory;
+    }
+
+    private MessageFactory createDefaultMessageFactory() {
+        return new ParameterizedMessageFactory();
     }
 
     /**