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 2022/01/10 23:08:22 UTC

[logging-log4j2] 02/03: Log4j 1.2 bridge class org.apache.log4j.spi.LoggingEvent missing constructors and public instance variable.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit c1ef50841b2818cb0ec45c4be05b7000a394d20a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 10 18:08:11 2022 -0500

    Log4j 1.2 bridge class org.apache.log4j.spi.LoggingEvent missing
    constructors and public instance variable.
---
 .../java/org/apache/log4j/spi/LoggingEvent.java    | 72 +++++++++++++++++++++-
 1 file changed, 69 insertions(+), 3 deletions(-)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java
index 34b1d18..f22c34e 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java
@@ -16,13 +16,14 @@
  */
 package org.apache.log4j.spi;
 
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.log4j.Category;
 import org.apache.log4j.Level;
+import org.apache.log4j.Priority;
 import org.apache.log4j.bridge.LogEventAdapter;
 
-import java.util.Map;
-import java.util.Set;
-
 /**
  *  No-op version of Log4j 1.2 LoggingEvent. This class is not directly used by Log4j 1.x clients but is used by
  *  the Log4j 2 LogEvent adapter to be compatible with Log4j 1.x components.
@@ -38,6 +39,71 @@ public class LoggingEvent {
         return LogEventAdapter.getStartTime();
     }
 
+    /**
+     * The number of milliseconds elapsed from 1/1/1970 until logging event was created.
+     */
+    public final long timeStamp;
+
+    /**
+     * Constructs a new instance.
+     */
+    public LoggingEvent() {
+        timeStamp = System.currentTimeMillis();
+    }
+
+    /**
+     * Create new instance.
+     * 
+     * @since 1.2.15
+     * @param fqnOfCategoryClass Fully qualified class name of Logger implementation.
+     * @param logger The logger generating this event.
+     * @param timeStamp the timestamp of this logging event
+     * @param level The level of this event.
+     * @param message The message of this event.
+     * @param threadName thread name
+     * @param throwable The throwable of this event.
+     * @param ndc Nested diagnostic context
+     * @param info Location info
+     * @param properties MDC properties
+     */
+    public LoggingEvent(final String fqnOfCategoryClass, final Category logger, final long timeStamp, final Level level, final Object message,
+        final String threadName, final ThrowableInformation throwable, final String ndc, final LocationInfo info, final Map properties) {
+        this.timeStamp = timeStamp;
+    }
+
+    /**
+     * Instantiate a LoggingEvent from the supplied parameters.
+     * 
+     * <p>
+     * Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed.
+     * <p>
+     * 
+     * @param logger The logger generating this event.
+     * @param timeStamp the timestamp of this logging event
+     * @param level The level of this event.
+     * @param message The message of this event.
+     * @param throwable The throwable of this event.
+     */
+    public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) {
+        this.timeStamp = timeStamp;
+    }
+
+    /**
+     * Instantiate a LoggingEvent from the supplied parameters.
+     * 
+     * <p>
+     * Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed.
+     * <p>
+     * 
+     * @param logger The logger generating this event.
+     * @param level The level of this event.
+     * @param message The message of this event.
+     * @param throwable The throwable of this event.
+     */
+    public LoggingEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) {
+        timeStamp = System.currentTimeMillis();
+    }
+
     public String getFQNOfLoggerClass() {
         return null;
     }