[LOGBack-dev] svn commit: r497 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic main/java/ch/qos/logback/classic/pattern main/java/ch/qos/logback/classic/spi test/java/ch/qos/logback/classic test/java/ch/qos/logback/classic/boolex test/java/ch/qos/logback/classic/joran test/java/ch/qos/logback/classic/pattern
noreply.seb at qos.ch
noreply.seb at qos.ch
Wed Aug 30 18:48:36 CEST 2006
Author: seb
Date: Wed Aug 30 18:48:35 2006
New Revision: 497
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
Log:
- Added - Added an Object[] argArray parameter to the LoggingEvent constructor.
- Updated client classes accordingly.
- Removed formattedMessage != null check in MessageConverter.
- Removed message formatting calls from Logger.
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Wed Aug 30 18:48:35 2006
@@ -358,34 +358,33 @@
return childLogger;
}
+ /**
+ * The next three methods could be merged.
+ * However, we decided not to merge them to make the calls to
+ * these methods more easily understandable, avoiding many instances
+ * of passing null parameters.
+ */
private void filterAndLog(String caller, Level level, String format,
Throwable t) {
- LoggingEvent le = new LoggingEvent(caller, this, level, format, t);
+ LoggingEvent le = new LoggingEvent(caller, this, level, format, t, null);
if (loggerContext.getFilterChainDecision(le) != Filter.DENY) {
- le.setFormattedMessage(format);
callAppenders(le);
}
}
private void filterAndLog(String caller, Level level, String format,
Object[] argArray, Throwable t) {
- LoggingEvent le = new LoggingEvent(caller, this, level, format, t);
- le.setArgumentArray(argArray);
+ LoggingEvent le = new LoggingEvent(caller, this, level, format, t, argArray);
if (loggerContext.getFilterChainDecision(le) != Filter.DENY) {
- String formattedMessage = MessageFormatter.arrayFormat(format, argArray);
- le.setFormattedMessage(formattedMessage);
callAppenders(le);
}
}
private void filterAndLog(String caller, Level level, Marker marker,
String format, Object[] argArray, Throwable t) {
- LoggingEvent le = new LoggingEvent(caller, this, level, format, t);
+ LoggingEvent le = new LoggingEvent(caller, this, level, format, t, argArray);
le.setMarker(marker);
- le.setArgumentArray(argArray);
if (loggerContext.getFilterChainDecision(le) != Filter.DENY) {
- String formattedMessage = MessageFormatter.arrayFormat(format, argArray);
- le.setFormattedMessage(formattedMessage);
callAppenders(le);
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java Wed Aug 30 18:48:35 2006
@@ -20,9 +20,6 @@
public String convert(Object event) {
LoggingEvent le = (LoggingEvent) event;
- if (le.getFormattedMessage() == null) {
- return le.getMessage();
- }
return le.getFormattedMessage();
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java Wed Aug 30 18:48:35 2006
@@ -18,6 +18,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
+import org.slf4j.impl.MessageFormatter;
import ch.qos.logback.classic.Level;
@@ -97,7 +98,7 @@
}
public LoggingEvent(String fqcn, Logger logger, Level level, String message,
- Throwable throwable) {
+ Throwable throwable, Object[] argArray) {
this.fqnOfLoggerClass = fqcn;
this.logger = logger;
this.level = level;
@@ -106,14 +107,13 @@
if (throwable != null) {
this.throwableInfo = new ThrowableInformation(throwable);
}
- timeStamp = System.currentTimeMillis();
- }
-
- public void setArgumentArray(Object[] argArray) {
- if (this.argumentArray != null) {
- throw new IllegalStateException("argArray has been already set");
+
+ if (argArray != null) {
+ formattedMessage = MessageFormatter.arrayFormat(message, argArray);
+ } else {
+ formattedMessage = message;
}
- this.argumentArray = argArray;
+ timeStamp = System.currentTimeMillis();
}
public Object[] getArgumentArray() {
@@ -257,14 +257,6 @@
return formattedMessage;
}
- public void setFormattedMessage(String formattedMessage) {
- if (this.formattedMessage != null) {
- throw new IllegalStateException(
- "The formatted message has been already set for this event.");
- }
- this.formattedMessage = formattedMessage;
- }
-
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
threadName = (String) in.readObject();
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java Wed Aug 30 18:48:35 2006
@@ -45,7 +45,7 @@
LoggingEvent makeLoggingEvent(Exception ex) {
return new LoggingEvent(ch.qos.logback.core.pattern.FormattingConverter.class
- .getName(), logger, Level.INFO, "Some message", ex);
+ .getName(), logger, Level.INFO, "Some message", ex, null);
}
public Object getEventObject() {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java Wed Aug 30 18:48:35 2006
@@ -32,7 +32,7 @@
LoggingEvent makeLoggingEvent(Exception ex) {
LoggingEvent e = new LoggingEvent(ch.qos.logback.core.pattern.FormattingConverter.class
- .getName(), logger, Level.INFO, "Some message", ex);
+ .getName(), logger, Level.INFO, "Some message", ex, null);
return e;
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java Wed Aug 30 18:48:35 2006
@@ -44,7 +44,7 @@
assertNotNull(evaluator);
Logger logger = loggerContext.getLogger("xx");
- LoggingEvent event = new LoggingEvent("foo", logger, Level.DEBUG, "Hello world",null);
+ LoggingEvent event = new LoggingEvent("foo", logger, Level.DEBUG, "Hello world", null, null);
StatusPrinter.print(loggerContext.getStatusManager());
assertTrue(evaluator.evaluate(event));
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java Wed Aug 30 18:48:35 2006
@@ -50,7 +50,7 @@
// particular test.
LoggingEvent makeLoggingEvent(Exception ex) {
return new LoggingEvent(ch.qos.logback.core.pattern.FormattingConverter.class
- .getName(), logger, Level.INFO, "Some message", ex);
+ .getName(), logger, Level.INFO, "Some message", ex, null);
}
Exception getException(String msg, Exception cause) {
More information about the logback-dev
mailing list