Author: rgoers
Date: Tue Oct 25 17:55:46 2011
New Revision: 1188834
URL: http://svn.apache.org/viewvc?rev=1188834&view=rev
Log:
Add TimestampMessage
Added:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
Added:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java?rev=1188834&view=auto
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
(added)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
Tue Oct 25 17:55:46 2011
@@ -0,0 +1,9 @@
+package org.apache.logging.log4j.message;
+
+/**
+ * Messages that use this interface will cause the timestamp in the message to
be used instead of the timestmap in
+ * the LogEvent.
+ */
+public interface TimestampMessage {
+ long getTimestamp();
+}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1188834&r1=1188833&r2=1188834&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
Tue Oct 25 17:55:46 2011
@@ -22,6 +22,7 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.filter.CompositeFilter;
import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
import java.util.ArrayList;
@@ -108,6 +109,9 @@ public class Logger extends AbstractLogg
@Override
public void log(Marker marker, String fqcn, Level level, Message data,
Throwable t) {
+ if (data == null) {
+ data = new SimpleMessage("");
+ }
config.loggerConfig.log(name, marker, fqcn, level, data, t);
}
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?rev=1188834&r1=1188833&r2=1188834&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
Tue Oct 25 17:55:46 2011
@@ -22,6 +22,7 @@ import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.message.LoggerNameAwareMessage;
import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.TimestampMessage;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -88,7 +89,7 @@ public class Log4jLogEvent implements Lo
this.throwable = t == null ? null : new ThrowableProxy(t);
this.mdc = mdc;
this.ndc = ndc;
- this.timestamp = timestamp;
+ this.timestamp = message instanceof TimestampMessage ?
((TimestampMessage) message).getTimestamp() : timestamp;
this.threadName = threadName;
this.location = location;
if (message != null && message instanceof LoggerNameAwareMessage) {