Expose MessageFactory and use logMessage

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/127ba287
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/127ba287
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/127ba287

Branch: refs/heads/LOG4J-1181
Commit: 127ba28789b201e358ec30023fd28fd36fe8e475
Parents: 06f7786
Author: Mikael StÃ¥ldal <[email protected]>
Authored: Thu Oct 29 17:31:01 2015 +0100
Committer: Mikael StÃ¥ldal <[email protected]>
Committed: Thu Oct 29 17:31:01 2015 +0100

----------------------------------------------------------------------
 .../org/apache/logging/log4j/scala/Logger.scala   | 18 +++++++++++++-----
 .../org/apache/logging/log4j/scala/Logger.scala   | 18 +++++++++++++-----
 2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/127ba287/log4j-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
----------------------------------------------------------------------
diff --git 
a/log4j-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala 
b/log4j-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
index 63cce4d..edf99b9 100644
--- 
a/log4j-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
+++ 
b/log4j-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
@@ -1,6 +1,6 @@
 package org.apache.logging.log4j.scala
 
-import org.apache.logging.log4j.message.Message
+import org.apache.logging.log4j.message.{MessageFactory, Message}
 import org.apache.logging.log4j.spi.ExtendedLogger
 import org.apache.logging.log4j.{Level, Marker}
 
@@ -186,7 +186,12 @@ class Logger(val delegate: ExtendedLogger) {
 
   def name: String = delegate.getName
 
-  /** Should normally not be used directly from application code, but needs to 
be public for access by macros.
+  def messageFactory: MessageFactory = delegate.getMessageFactory
+
+  /** Always logs a message at the specified level. It is the responsibility 
of the caller to ensure the specified
+    * level is enabled.
+    *
+    * Should normally not be used directly from application code, but needs to 
be public for access by macros.
     *
     * @param level    log level
     * @param marker   marker or `null`
@@ -194,10 +199,13 @@ class Logger(val delegate: ExtendedLogger) {
     * @param cause    cause or `null`
     */
   def logMessage(level: Level, marker: Marker, message: Message, cause: 
Throwable): Unit = {
-    delegate.logIfEnabled(FQCN, level, marker, message, cause)
+    delegate.logMessage(FQCN, level, marker, message, cause)
   }
 
-  /** Should normally not be used directly from application code, but needs to 
be public for access by macros.
+  /** Always logs a message at the specified level. It is the responsibility 
of the caller to ensure the specified
+    * level is enabled.
+    *
+    * Should normally not be used directly from application code, but needs to 
be public for access by macros.
     *
     * @param level    log level
     * @param marker   marker or `null`
@@ -205,7 +213,7 @@ class Logger(val delegate: ExtendedLogger) {
     * @param cause    cause or `null`
     */
   def logMessage(level: Level, marker: Marker, message: String, cause: 
Throwable): Unit = {
-    delegate.logIfEnabled(FQCN, level, marker, message, cause)
+    delegate.logMessage(FQCN, level, marker, 
delegate.getMessageFactory.newMessage(message), cause)
   }
 
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/127ba287/log4j-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
----------------------------------------------------------------------
diff --git 
a/log4j-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala 
b/log4j-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
index 63cce4d..edf99b9 100644
--- 
a/log4j-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
+++ 
b/log4j-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala
@@ -1,6 +1,6 @@
 package org.apache.logging.log4j.scala
 
-import org.apache.logging.log4j.message.Message
+import org.apache.logging.log4j.message.{MessageFactory, Message}
 import org.apache.logging.log4j.spi.ExtendedLogger
 import org.apache.logging.log4j.{Level, Marker}
 
@@ -186,7 +186,12 @@ class Logger(val delegate: ExtendedLogger) {
 
   def name: String = delegate.getName
 
-  /** Should normally not be used directly from application code, but needs to 
be public for access by macros.
+  def messageFactory: MessageFactory = delegate.getMessageFactory
+
+  /** Always logs a message at the specified level. It is the responsibility 
of the caller to ensure the specified
+    * level is enabled.
+    *
+    * Should normally not be used directly from application code, but needs to 
be public for access by macros.
     *
     * @param level    log level
     * @param marker   marker or `null`
@@ -194,10 +199,13 @@ class Logger(val delegate: ExtendedLogger) {
     * @param cause    cause or `null`
     */
   def logMessage(level: Level, marker: Marker, message: Message, cause: 
Throwable): Unit = {
-    delegate.logIfEnabled(FQCN, level, marker, message, cause)
+    delegate.logMessage(FQCN, level, marker, message, cause)
   }
 
-  /** Should normally not be used directly from application code, but needs to 
be public for access by macros.
+  /** Always logs a message at the specified level. It is the responsibility 
of the caller to ensure the specified
+    * level is enabled.
+    *
+    * Should normally not be used directly from application code, but needs to 
be public for access by macros.
     *
     * @param level    log level
     * @param marker   marker or `null`
@@ -205,7 +213,7 @@ class Logger(val delegate: ExtendedLogger) {
     * @param cause    cause or `null`
     */
   def logMessage(level: Level, marker: Marker, message: String, cause: 
Throwable): Unit = {
-    delegate.logIfEnabled(FQCN, level, marker, message, cause)
+    delegate.logMessage(FQCN, level, marker, 
delegate.getMessageFactory.newMessage(message), cause)
   }
 
 }

Reply via email to