logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1615449 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
Date Sun, 03 Aug 2014 20:28:54 GMT
Author: mattsicker
Date: Sun Aug  3 20:28:53 2014
New Revision: 1615449

URL: http://svn.apache.org/r1615449
Log:
Add LogEvent builder.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?rev=1615449&r1=1615448&r2=1615449&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
Sun Aug  3 20:28:53 2014
@@ -58,6 +58,55 @@ public class Log4jLogEvent implements Lo
     private boolean includeLocation;
     private boolean endOfBatch = false;
 
+    public static class Builder implements org.apache.logging.log4j.core.util.Builder<LogEvent>
{
+
+        private String loggerFqcn;
+        private Marker marker;
+        private Level level;
+        private String loggerName;
+        private Message message;
+        private Throwable thrown;
+
+        public Builder setLoggerFqcn(String loggerFqcn) {
+            this.loggerFqcn = loggerFqcn;
+            return this;
+        }
+
+        public Builder setMarker(Marker marker) {
+            this.marker = marker;
+            return this;
+        }
+
+        public Builder setLevel(Level level) {
+            this.level = level;
+            return this;
+        }
+
+        public Builder setLoggerName(String loggerName) {
+            this.loggerName = loggerName;
+            return this;
+        }
+
+        public Builder setMessage(Message message) {
+            this.message = message;
+            return this;
+        }
+
+        public Builder setThrown(Throwable thrown) {
+            this.thrown = thrown;
+            return this;
+        }
+
+        @Override
+        public Log4jLogEvent build() {
+            return new Log4jLogEvent(loggerName, marker, loggerFqcn, level, message, thrown);
+        }
+    }
+
+    public static Builder newBuilder() {
+        return new Builder();
+    }
+
     public Log4jLogEvent() {
         this(clock.currentTimeMillis());
     }



Mime
View raw message