remkop commented on a change in pull request #284: LOG4J2-2639 - Allow logging 
calls to be constructed using a builder pattern
URL: https://github.com/apache/logging-log4j2/pull/284#discussion_r296555203
 
 

 ##########
 File path: 
log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
 ##########
 @@ -2755,77 +2755,114 @@ public void warn(final String message, final Object 
p0, final Object p1, final O
      * @since 3.0
      */
     @Override
-    public  LogBuilder atTrace() {
+    public  LogBuilder trace() {
         if (isTraceEnabled()) {
-            return logBuilder.get().setLevel(Level.TRACE);
+            DefaultLogBuilder builder = logBuilder.get();
+            if (builder.isInUse()) {
+                return new DefaultLogBuilder(this);
+            }
+            return builder.setLevel(Level.TRACE);
         } else {
-            return LogBuilder.INSTANCE;
+            return LogBuilder.NOOP;
         }
     }
     /**
-     * Constuct a trace log event.
+     * Constuct a debug log event.
      * @return a LogBuilder.
      * @since 3.0
      */
     @Override
-    public LogBuilder atDebug() {
+    public LogBuilder debug() {
         if (isDebugEnabled()) {
+            DefaultLogBuilder builder = logBuilder.get();
+            if (builder.isInUse()) {
+                return new DefaultLogBuilder(this);
+            }
             return logBuilder.get().setLevel(Level.DEBUG);
         } else {
-            return LogBuilder.INSTANCE;
+            return LogBuilder.NOOP;
 
 Review comment:
   The above 7 lines are repeated for each log level. Would it be possible to 
extract this to a helper method?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to