[logback-dev] svn commit: r2174 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic logback-classic/src/main/java/ch/qos/logback/classic/boolex logback-classic/src/main/java/ch/qos/logback/classic/db logback-classic/src/main/java/ch/qos/logback/classic/html logback-classic/src/main/java/ch/qos/logback/classic/log4j logback-classic/src/main/java/ch/qos/logback/classic/net logback-classic/src/main/java/ch/qos/logback/classic/pattern logback-classic/src/main/java/ch/qos/logback/classic/selector logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet logback-classic/src/main/java/ch/qos/logback/classic/spi logback-classic/src/main/java/org/slf4j/impl logback-classic/src/test/java/ch/qos/logback/classic logback-classic/src/test/java/ch/qos/logback/classic/control logback-classic/src/test/java/ch/qos/logback/classic/db logback-classic/src/test/java/ch/qos/logback/classic/html logback-classic/src/test/java/ch/qos/logback/classic/net logback-classic/src/ test/java/ch/qos/logback/classic/net/testObjectBuilders logback-classic/src/test/java/ch/qos/logback/classic/pattern logback-classic/src/test/java/ch/qos/logback/classic/selector logback-classic/src/test/java/ch/qos/logback/classic/spi logback-classic/src/test/java/ch/qos/logback/classic/spi/special logback-classic/src/test/java/ch/qos/logback/classic/turbo logback-core/src/main/java/ch/qos/logback/core/html logback-examples/src/main/java/chapter5 logback-site/src/site/pages
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Feb 27 17:23:01 CET 2009
Author: ceki
Date: Fri Feb 27 17:23:01 2009
New Revision: 2174
Added:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
- copied, changed from r2131, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicGlobal.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java
- copied, changed from r2170, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
- copied, changed from r2171, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventSDO.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPointUtil.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java
- copied, changed from r2131, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java
Removed:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicGlobal.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventSDO.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableToDataPointArray.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java
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/LoggerContext.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java
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/STEUtil.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPoint.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
logback/trunk/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventExt.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java
logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java
logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java
logback/trunk/logback-site/src/site/pages/news.html
Log:
Refactoring of the ThrowableProxy class.
ThrowableProxy now implements the IThrowableProxy interface as shown below:
public interface IThrowableProxy {
public String getClassName();
public String getMessage();
public ThrowableDataPoint[] getThrowableDataPointArray();
public int getCommonFrames();
public IThrowableProxy getCause(); <-- Joern smiles
}
Instead of being a flat structure, ThrowableProxy now contains nested
exceptions (cause) as a nested ThrowableProxy references. This was
requested by Joern Huxhorn on several occasions.
Classes printing threads had to be modified as a result of this
refactoring.
The ILoggerEvent interface has also been slightly refactored. The
LoggerRemoteView class is no longer referenced. Instead the
LoggerContextVO class is used. As a result, serialized events are
larger by a few bytes, but the code is hopefully much clearer.
In response to comments from the dev mailing list, the LoggingEventSDO
class has been renamed as LoggingEventVO.
Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java (from r2131, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicGlobal.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicGlobal.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java Fri Feb 27 17:23:01 2009
@@ -1,7 +1,7 @@
/**
* Logback: the generic, reliable, fast and flexible logging framework.
*
- * Copyright (C) 2000-2008, QOS.ch
+ * Copyright (C) 2000-2009, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -9,11 +9,20 @@
*/
package ch.qos.logback.classic;
-public class ClassicGlobal {
+public class ClassicConstants {
static public final char LOGGER_SEPARATOR = '.';
static public final String USER_MDC_KEY = "user";
public static final String LOGBACK_CONTEXT_SELECTOR = "logback.ContextSelector";
public static String JNDI_CONFIGURATION_RESOURCE = "java:comp/env/logback/configuration-resource";
public static String JNDI_CONTEXT_NAME = "java:comp/env/logback/context-name";
+
+
+ /**
+ * The maximum number of package separators (dots) that abbreviation algorithms
+ * can handle. Class or logger names with more separators will have their first
+ * MAX_DOTS parts shortened.
+ *
+ */
+ public static final int MAX_DOTS = 16;
}
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 Fri Feb 27 17:23:01 2009
@@ -299,11 +299,11 @@
* @return
*/
Logger createChildByLastNamePart(final String lastPart) {
- int i_index = lastPart.indexOf(ClassicGlobal.LOGGER_SEPARATOR);
+ int i_index = lastPart.indexOf(ClassicConstants.LOGGER_SEPARATOR);
if (i_index != -1) {
throw new IllegalArgumentException("Child name [" + lastPart
+ " passed as parameter, may not include ["
- + ClassicGlobal.LOGGER_SEPARATOR + "]");
+ + ClassicConstants.LOGGER_SEPARATOR + "]");
}
if (childrenList == null) {
@@ -314,7 +314,7 @@
childLogger = new Logger(lastPart, this, this.loggerContext);
} else {
childLogger = new Logger(
- name + ClassicGlobal.LOGGER_SEPARATOR + lastPart, this,
+ name + ClassicConstants.LOGGER_SEPARATOR + lastPart, this,
this.loggerContext);
}
childrenList.add(childLogger);
@@ -350,7 +350,7 @@
static private final int DEFAULT_CHILD_ARRAY_SIZE = 5;
Logger createChildByName(final String childName) {
- int i_index = childName.indexOf(ClassicGlobal.LOGGER_SEPARATOR, this.name
+ int i_index = childName.indexOf(ClassicConstants.LOGGER_SEPARATOR, this.name
.length() + 1);
if (i_index != -1) {
throw new IllegalArgumentException("For logger [" + this.name
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java Fri Feb 27 17:23:01 2009
@@ -22,7 +22,7 @@
import ch.qos.logback.classic.spi.LoggerComparator;
import ch.qos.logback.classic.spi.LoggerContextListener;
-import ch.qos.logback.classic.spi.LoggerContextRemoteView;
+import ch.qos.logback.classic.spi.LoggerContextVO;
import ch.qos.logback.classic.spi.TurboFilterList;
import ch.qos.logback.classic.turbo.TurboFilter;
import ch.qos.logback.core.ContextBase;
@@ -58,15 +58,16 @@
// footprint.
private Hashtable<String, Logger> loggerCache;
- private LoggerContextRemoteView loggerContextRemoteView;
+ private LoggerContextVO loggerContextRemoteView;
private final TurboFilterList turboFilterList = new TurboFilterList();
-
+ private boolean packagingDataEnabled = true;
+
boolean started = false;
public LoggerContext() {
super();
this.loggerCache = new Hashtable<String, Logger>();
- this.loggerContextRemoteView = new LoggerContextRemoteView(this);
+ this.loggerContextRemoteView = new LoggerContextVO(this);
this.root = new Logger(ROOT_NAME, null, this);
this.root.setLevel(Level.DEBUG);
loggerCache.put(ROOT_NAME, root);
@@ -79,7 +80,7 @@
* name or propertyMap (including keys or values) changes.
*/
private void syncRemoteView() {
- loggerContextRemoteView = new LoggerContextRemoteView(this);
+ loggerContextRemoteView = new LoggerContextVO(this);
for (Logger logger : loggerCache.values()) {
logger.buildRemoteView();
}
@@ -128,7 +129,7 @@
// in between as well (if they don't already exist)
String childName;
while (true) {
- int h = name.indexOf(ClassicGlobal.LOGGER_SEPARATOR, i);
+ int h = name.indexOf(ClassicConstants.LOGGER_SEPARATOR, i);
if (h == -1) {
childName = name;
} else {
@@ -185,10 +186,19 @@
return loggerList;
}
- public LoggerContextRemoteView getLoggerContextRemoteView() {
+ public LoggerContextVO getLoggerContextRemoteView() {
return loggerContextRemoteView;
}
+ public void setPackagingDataEnabled(boolean packagingDataEnabled) {
+ this.packagingDataEnabled = packagingDataEnabled;
+ }
+
+ public boolean isPackagingDataEnabled() {
+ return packagingDataEnabled;
+ }
+
+
/**
* This method closes all appenders,
*/
@@ -324,4 +334,5 @@
public String toString() {
return this.getClass().getName() + "[" + getName() + "]";
}
+
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java Fri Feb 27 17:23:01 2009
@@ -16,8 +16,9 @@
import org.slf4j.Marker;
import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggerContextVO;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
import ch.qos.logback.core.boolex.Matcher;
@@ -41,6 +42,7 @@
DEFAULT_PARAM_NAME_LIST.add("event");
DEFAULT_PARAM_NAME_LIST.add("message");
DEFAULT_PARAM_NAME_LIST.add("logger");
+ DEFAULT_PARAM_NAME_LIST.add("loggerContext");
DEFAULT_PARAM_NAME_LIST.add("level");
DEFAULT_PARAM_NAME_LIST.add("timeStamp");
DEFAULT_PARAM_NAME_LIST.add("marker");
@@ -55,12 +57,13 @@
DEFAULT_PARAM_TYPE_LIST.add(ILoggingEvent.class);
DEFAULT_PARAM_TYPE_LIST.add(String.class);
- DEFAULT_PARAM_TYPE_LIST.add(LoggerRemoteView.class);
+ DEFAULT_PARAM_TYPE_LIST.add(String.class);
+ DEFAULT_PARAM_TYPE_LIST.add(LoggerContextVO.class);
DEFAULT_PARAM_TYPE_LIST.add(int.class);
DEFAULT_PARAM_TYPE_LIST.add(long.class);
DEFAULT_PARAM_TYPE_LIST.add(Marker.class);
DEFAULT_PARAM_TYPE_LIST.add(Map.class);
- DEFAULT_PARAM_TYPE_LIST.add(Throwable.class);
+ DEFAULT_PARAM_TYPE_LIST.add(IThrowableProxy.class);
}
@@ -105,13 +108,14 @@
values[i++] = loggingEvent;
values[i++] = loggingEvent.getMessage();
- values[i++] = loggingEvent.getLoggerRemoteView();
+ values[i++] = loggingEvent.getLoggerName();
+ values[i++] = loggingEvent.getLoggerContextVO();
values[i++] = loggingEvent.getLevel().toInteger();
values[i++] = new Long(loggingEvent.getTimeStamp());
values[i++] = loggingEvent.getMarker();
values[i++] = loggingEvent.getMDCPropertyMap();
if (loggingEvent.getThrowableProxy() != null) {
- values[i++] = loggingEvent.getThrowableProxy().getThrowable();
+ values[i++] = loggingEvent.getThrowableProxy();
} else {
values[i++] = null;
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java Fri Feb 27 17:23:01 2009
@@ -100,7 +100,7 @@
throws SQLException {
stmt.setLong(1, event.getTimeStamp());
stmt.setString(2, event.getFormattedMessage());
- stmt.setString(3, event.getLoggerRemoteView().getName());
+ stmt.setString(3, event.getLoggerName());
stmt.setString(4, event.getLevel().toString());
stmt.setString(5, event.getThreadName());
stmt.setShort(6, DBHelper.computeReferenceMask(event));
@@ -123,8 +123,7 @@
// we consider that event-specific properties should have priority over
// context-wide
// properties.
- Map<String, String> loggerContextMap = event.getLoggerRemoteView()
- .getLoggerContextView().getPropertyMap();
+ Map<String, String> loggerContextMap = event.getLoggerContextVO().getPropertyMap();
Map<String, String> mdcMap = event.getMDCPropertyMap();
if (loggerContextMap != null) {
mergedMap.putAll(loggerContextMap);
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java Fri Feb 27 17:23:01 2009
@@ -11,7 +11,6 @@
package ch.qos.logback.classic.db;
import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.classic.spi.ThrowableDataPoint;
/**
* @author Ceki Gülcü
@@ -30,19 +29,15 @@
mdcPropSize = event.getMDCPropertyMap().keySet().size();
}
int contextPropSize = 0;
- if (event.getLoggerRemoteView().getLoggerContextView().getPropertyMap() != null) {
- contextPropSize = event.getLoggerRemoteView().getLoggerContextView()
- .getPropertyMap().size();
+ if (event.getLoggerContextVO().getPropertyMap() != null) {
+ contextPropSize = event.getLoggerContextVO().getPropertyMap().size();
}
if (mdcPropSize > 0 || contextPropSize > 0) {
mask = PROPERTIES_EXIST;
}
if (event.getThrowableProxy() != null) {
- ThrowableDataPoint[] tdpArray = event.getThrowableProxy().getThrowableDataPointArray();
- if (tdpArray != null) {
- mask |= EXCEPTION_EXISTS;
- }
+ mask |= EXCEPTION_EXISTS;
}
return mask;
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java Fri Feb 27 17:23:01 2009
@@ -9,50 +9,50 @@
*/
package ch.qos.logback.classic.html;
-import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
-import ch.qos.logback.classic.spi.ThrowableProxy;
+import ch.qos.logback.classic.spi.ThrowableProxyUtil;
+import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.helpers.Transform;
import ch.qos.logback.core.html.IThrowableRenderer;
-public class DefaultThrowableRenderer implements IThrowableRenderer {
+public class DefaultThrowableRenderer implements IThrowableRenderer<ILoggingEvent> {
static final String TRACE_PREFIX = "<br /> ";
- Throwable throwable;
-
public DefaultThrowableRenderer() {
-
- }
-
- public void setThrowable(Throwable t) {
- this.throwable = t;
}
- public void render(StringBuilder sbuf, ThrowableDataPoint[] tdpArray) {
- if (tdpArray != null) {
- int len = tdpArray.length;
- if (len == 0) {
- return;
- }
- sbuf.append("<tr><td class=\"Exception\" colspan=\"6\">");
- sbuf.append(Transform.escapeTags(tdpArray[0].toString()));
- sbuf.append(LINE_SEPARATOR);
- for (int i = 1; i < len; i++) {
- sbuf.append(TRACE_PREFIX);
- sbuf.append(Transform.escapeTags(tdpArray[i].toString()));
- sbuf.append(LINE_SEPARATOR);
- }
- sbuf.append("</td></tr>");
+ void render(StringBuilder sbuf, IThrowableProxy tp) {
+ StringBuilder firstLine = new StringBuilder();
+ ThrowableProxyUtil.printFirstLine(firstLine, tp);
+ sbuf.append(Transform.escapeTags(firstLine.toString()));
+
+ int commonFrames = tp.getCommonFrames();
+ ThrowableDataPoint[] tdpa = tp.getThrowableDataPointArray();
+
+ for (int i = 0; i < tdpa.length - commonFrames; i++) {
+ ThrowableDataPoint tdp = tdpa[i];
+ sbuf.append(TRACE_PREFIX);
+ sbuf.append(Transform.escapeTags(tdp.toString()));
+ sbuf.append(CoreConstants.LINE_SEPARATOR);
+ }
+
+ if (commonFrames > 0) {
+ sbuf.append(TRACE_PREFIX);
+ sbuf.append("\t... " + commonFrames).append(" common frames omitted")
+ .append(CoreConstants.LINE_SEPARATOR);
}
}
- public void render(StringBuilder sbuf, Object eventObject) {
- ILoggingEvent event = (ILoggingEvent)eventObject;
- ThrowableProxy tp = event.getThrowableProxy();
- if (tp != null) {
- render(sbuf, tp.getThrowableDataPointArray());
+ public void render(StringBuilder sbuf, ILoggingEvent event) {
+ IThrowableProxy tp = event.getThrowableProxy();
+ sbuf.append("<tr><td class=\"Exception\" colspan=\"6\">");
+ while(tp != null) {
+ render(sbuf, tp);
+ tp = tp.getCause();
}
+ sbuf.append("</td></tr>");
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java Fri Feb 27 17:23:01 2009
@@ -39,7 +39,7 @@
*/
static final String DEFAULT_CONVERSION_PATTERN = "%date%thread%level%logger%mdc%msg";
- IThrowableRenderer throwableRenderer;
+ IThrowableRenderer<ILoggingEvent> throwableRenderer;
/**
* Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN.
@@ -117,7 +117,7 @@
return throwableRenderer;
}
- public void setThrowableRenderer(IThrowableRenderer throwableRenderer) {
+ public void setThrowableRenderer(IThrowableRenderer<ILoggingEvent> throwableRenderer) {
this.throwableRenderer = throwableRenderer;
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java Fri Feb 27 17:23:01 2009
@@ -15,8 +15,8 @@
import ch.qos.logback.classic.spi.CallerData;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
-import ch.qos.logback.classic.spi.ThrowableProxy;
import ch.qos.logback.core.LayoutBase;
import ch.qos.logback.core.helpers.Transform;
@@ -103,7 +103,7 @@
// We yield to the \r\n heresy.
buf.append("<log4j:event logger=\"");
- buf.append(event.getLoggerRemoteView().getName());
+ buf.append(event.getLoggerName());
buf.append("\"\r\n");
buf.append(" timestamp=\"");
buf.append(event.getTimeStamp());
@@ -122,11 +122,11 @@
// logback does not support NDC
// String ndc = event.getNDC();
- ThrowableProxy tp = event.getThrowableProxy();
+ IThrowableProxy tp = event.getThrowableProxy();
if (tp != null) {
- buf.append(" <log4j:throwable><![CDATA[");
ThrowableDataPoint[] tdpArray = tp.getThrowableDataPointArray();
+ buf.append(" <log4j:throwable><![CDATA[");
for (ThrowableDataPoint tdp : tdpArray) {
buf.append(tdp.toString());
buf.append("\r\n");
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java Fri Feb 27 17:23:01 2009
@@ -117,7 +117,7 @@
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
event = (ILoggingEvent) objectMessage.getObject();
- Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerRemoteView().getName());
+ Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerName());
log.callAppenders(event);
} else {
logger.warn("Received message is of type " + message.getJMSType()
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java Fri Feb 27 17:23:01 2009
@@ -117,7 +117,7 @@
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
event = (ILoggingEvent) objectMessage.getObject();
- Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerRemoteView().getName());
+ Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerName());
log.callAppenders(event);
} else {
logger.warn("Received message is of type " + message.getJMSType()
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java Fri Feb 27 17:23:01 2009
@@ -13,7 +13,7 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
-import ch.qos.logback.classic.spi.LoggingEventSDO;
+import ch.qos.logback.classic.spi.LoggingEventVO;
import ch.qos.logback.core.spi.PreSerializationTransformer;
public class LoggingEventPreSerializationTransformer implements
@@ -24,9 +24,9 @@
return null;
}
if (event instanceof LoggingEvent) {
- return LoggingEventSDO.build(event);
- } else if (event instanceof LoggingEventSDO) {
- return (LoggingEventSDO) event;
+ return LoggingEventVO.build(event);
+ } else if (event instanceof LoggingEventVO) {
+ return (LoggingEventVO) event;
} else {
throw new IllegalArgumentException("Unsupported type "+event.getClass().getName());
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java Fri Feb 27 17:23:01 2009
@@ -78,7 +78,7 @@
event = (ILoggingEvent) ois.readObject();
// get a logger from the hierarchy. The name of the logger is taken to
// be the name contained in the event.
- remoteLogger = context.getLogger(event.getLoggerRemoteView().getName());
+ remoteLogger = context.getLogger(event.getLoggerName());
// apply the logger-level filter
if (remoteLogger.isEnabledFor(event.getLevel())) {
// finally log the event as if was generated locally
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java Fri Feb 27 17:23:01 2009
@@ -14,6 +14,7 @@
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.pattern.SyslogStartConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
import ch.qos.logback.classic.util.LevelToSyslogSeverity;
import ch.qos.logback.core.Layout;
@@ -21,10 +22,8 @@
import ch.qos.logback.core.net.SyslogWriter;
/**
- * This appender can be used to send messages to a remote
- * syslog daemon.
- * <p>
- * For more information about this appender, please refer to the online manual at
+ * This appender can be used to send messages to a remote syslog daemon. <p> For
+ * more information about this appender, please refer to the online manual at
* http://logback.qos.ch/manual/appenders.html#SyslogAppender
*
* @author Ceki Gülcü
@@ -37,17 +36,17 @@
public Layout<ILoggingEvent> buildLayout(String facilityStr) {
String prefixPattern = "%syslogStart{" + facilityStr + "}%nopex";
-
+
prefixLayout.getInstanceConverterMap().put("syslogStart",
SyslogStartConverter.class.getName());
prefixLayout.setPattern(prefixPattern);
prefixLayout.setContext(getContext());
prefixLayout.start();
-
+
PatternLayout fullLayout = new PatternLayout();
fullLayout.getInstanceConverterMap().put("syslogStart",
SyslogStartConverter.class.getName());
-
+
if (suffixPattern == null) {
suffixPattern = DEFAULT_SUFFIX_PATTERN;
}
@@ -73,20 +72,21 @@
@Override
protected void postProcess(Object eventObject, SyslogWriter sw) {
ILoggingEvent event = (ILoggingEvent) eventObject;
-
+
String prefix = prefixLayout.doLayout(event);
-
- if (event.getThrowableProxy() != null) {
- ThrowableDataPoint[] strRep = event.getThrowableProxy().getThrowableDataPointArray();
+
+ IThrowableProxy tp = event.getThrowableProxy();
+ while (tp != null) {
+ ThrowableDataPoint[] strRep = tp.getThrowableDataPointArray();
try {
for (ThrowableDataPoint line : strRep) {
sw.write(prefix + line.toString());
sw.flush();
}
} catch (IOException e) {
+ break;
}
+ tp = tp.getCause();
}
-
}
-
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java Fri Feb 27 17:23:01 2009
@@ -13,7 +13,6 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
-import ch.qos.logback.classic.spi.ThrowableProxy;
public class ExtendedThrowableProxyConverter extends ThrowableProxyConverter {
@@ -31,8 +30,7 @@
}
protected void prepareLoggingEvent(ILoggingEvent event) {
- ThrowableProxy tp = event.getThrowableProxy();
- tp.calculatePackagingData();
+
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java Fri Feb 27 17:23:01 2009
@@ -14,6 +14,6 @@
public class LoggerConverter extends NamedConverter {
protected String getFullyQualifiedName(ILoggingEvent event) {
- return event.getLoggerRemoteView().getName();
+ return event.getLoggerName();
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java Fri Feb 27 17:23:01 2009
@@ -25,7 +25,7 @@
return timesmapStr;
} else {
lastTimestamp = timestamp;
- timesmapStr = Long.toString(timestamp - event.getContextBirthTime());
+ timesmapStr = Long.toString(timestamp - event.getLoggerContextVO().getBirthTime());
return timesmapStr;
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java Fri Feb 27 17:23:01 2009
@@ -39,10 +39,12 @@
}
buf.setLength(0);
- int[] dotArray = new int[ClassicConstants.MAX_DOTS];
+ int[] dotIndexesArray = new int[ClassicConstants.MAX_DOTS];
+ // a.b.c contains 2 dots but 2+1 parts.
+ // see also http://jira.qos.ch/browse/LBCLASSIC-110
int[] lengthArray = new int[ClassicConstants.MAX_DOTS+1];
- int dotCount = computeIndexes(fqClassName, dotArray);
+ int dotCount = computeDotIndexes(fqClassName, dotIndexesArray);
// System.out.println();
// System.out.println("Dot count for [" + className + "] is " + dotCount);
@@ -51,13 +53,13 @@
return fqClassName;
}
// printArray("dotArray: ", dotArray);
- computeLengthArray(fqClassName, dotArray, lengthArray, dotCount);
+ computeLengthArray(fqClassName, dotIndexesArray, lengthArray, dotCount);
// printArray("lengthArray: ", lengthArray);
for (int i = 0; i <= dotCount; i++) {
if (i == 0) {
buf.append(fqClassName.substring(0, lengthArray[i] - 1));
} else {
- buf.append(fqClassName.substring(dotArray[i - 1], dotArray[i - 1]
+ buf.append(fqClassName.substring(dotIndexesArray[i - 1], dotIndexesArray[i - 1]
+ lengthArray[i]));
}
// System.out.println("i=" + i + ", buf=" + buf);
@@ -67,7 +69,7 @@
}
- static int computeIndexes(final String className, int[] dotArray) {
+ static int computeDotIndexes(final String className, int[] dotArray) {
int dotCount = 0;
int k = 0;
while (true) {
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java Fri Feb 27 17:23:01 2009
@@ -14,8 +14,9 @@
import java.util.Map;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
-import ch.qos.logback.classic.spi.ThrowableProxy;
+import ch.qos.logback.classic.spi.ThrowableProxyUtil;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.boolex.EvaluationException;
@@ -67,7 +68,8 @@
String evaluatorStr = (String) optionList.get(i);
Context context = getContext();
Map evaluatorMap = (Map) context.getObject(CoreConstants.EVALUATOR_MAP);
- EventEvaluator<ILoggingEvent> ee = (EventEvaluator<ILoggingEvent>) evaluatorMap.get(evaluatorStr);
+ EventEvaluator<ILoggingEvent> ee = (EventEvaluator<ILoggingEvent>) evaluatorMap
+ .get(evaluatorStr);
addEvaluator(ee);
}
}
@@ -89,26 +91,16 @@
protected void extraData(StringBuilder builder, ThrowableDataPoint tdp) {
// nop
}
-
- protected void prepareLoggingEvent(ILoggingEvent event) {
- // nop
- }
-
+
public String convert(ILoggingEvent event) {
StringBuilder buf = new StringBuilder(32);
- ThrowableProxy information = event.getThrowableProxy();
-
- if (information == null) {
+ IThrowableProxy tp = event.getThrowableProxy();
+ if (tp == null) {
return CoreConstants.EMPTY_STRING;
}
- ThrowableDataPoint[] tdpArray = information.getThrowableDataPointArray();
-
- int length = (lengthOption > tdpArray.length) ? tdpArray.length
- : lengthOption;
-
- // an evaluator match will cause stack printing to be skipped
+ // an evaluator match will cause stack printing to be skipped
if (evaluatorList != null) {
boolean printStack = true;
for (int i = 0; i < evaluatorList.size(); i++) {
@@ -127,8 +119,9 @@
ErrorStatus errorStatus = new ErrorStatus(
"Exception thrown for evaluator named [" + ee.getName() + "].",
this, eex);
- errorStatus.add(new ErrorStatus("This was the last warning about this evaluator's errors." +
- "We don't want the StatusManager to get flooded.", this));
+ errorStatus.add(new ErrorStatus(
+ "This was the last warning about this evaluator's errors."
+ + "We don't want the StatusManager to get flooded.", this));
addStatus(errorStatus);
}
}
@@ -139,17 +132,38 @@
}
}
- prepareLoggingEvent(event);
-
- buf.append(tdpArray[0]).append(CoreConstants.LINE_SEPARATOR);
- for (int i = 1; i < length; i++) {
+ while (tp != null) {
+ printThrowableProxy(buf, tp);
+ tp = tp.getCause();
+ }
+ return buf.toString();
+ }
+
+ void printThrowableProxy(StringBuilder buf, IThrowableProxy tp) {
+ ThrowableProxyUtil.printFirstLine(buf, tp);
+
+ ThrowableDataPoint[] tdpArray = tp.getThrowableDataPointArray();
+ int commonFrames = tp.getCommonFrames();
+
+ boolean unrestrictedPrinting = lengthOption > tdpArray.length;
+ int length = (unrestrictedPrinting) ? tdpArray.length : lengthOption;
+
+
+ int maxIndex = length;
+ if (commonFrames > 0 && unrestrictedPrinting) {
+ maxIndex -= commonFrames;
+ }
+
+ for (int i = 0; i < maxIndex; i++) {
String string = tdpArray[i].toString();
buf.append(string);
- extraData(buf, tdpArray[i]); // allow other data to be appended
+ extraData(buf, tdpArray[i]); // allow other data to be added
buf.append(CoreConstants.LINE_SEPARATOR);
}
- return buf.toString();
+ if (commonFrames > 0 && unrestrictedPrinting) {
+ buf.append("\t... " + tp.getCommonFrames()).append(
+ " common frames omitted").append(CoreConstants.LINE_SEPARATOR);
+ }
}
-
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java Fri Feb 27 17:23:01 2009
@@ -9,8 +9,8 @@
*/
package ch.qos.logback.classic.selector;
-import static ch.qos.logback.classic.ClassicGlobal.JNDI_CONFIGURATION_RESOURCE;
-import static ch.qos.logback.classic.ClassicGlobal.JNDI_CONTEXT_NAME;
+import static ch.qos.logback.classic.ClassicConstants.JNDI_CONFIGURATION_RESOURCE;
+import static ch.qos.logback.classic.ClassicConstants.JNDI_CONTEXT_NAME;
import java.net.URL;
import java.util.ArrayList;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java Fri Feb 27 17:23:01 2009
@@ -10,7 +10,7 @@
package ch.qos.logback.classic.selector.servlet;
-import static ch.qos.logback.classic.ClassicGlobal.JNDI_CONTEXT_NAME;
+import static ch.qos.logback.classic.ClassicConstants.JNDI_CONTEXT_NAME;
import javax.naming.Context;
import javax.naming.NamingException;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java Fri Feb 27 17:23:01 2009
@@ -19,20 +19,14 @@
public Object[] getArgumentArray();
public String getFormattedMessage();
- public LoggerRemoteView getLoggerRemoteView();
-
- public ThrowableProxy getThrowableProxy();
+ public String getLoggerName();
+ public LoggerContextVO getLoggerContextVO();
+ public IThrowableProxy getThrowableProxy();
public CallerData[] getCallerData();
-
public Marker getMarker();
-
public Map<String, String> getMDCPropertyMap();
-
public long getTimeStamp();
-
- public long getContextBirthTime();
-
public void prepareForDeferredProcessing();
}
Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java Fri Feb 27 17:23:01 2009
@@ -0,0 +1,23 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2009, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.classic.spi;
+
+public interface IThrowableProxy {
+
+ public String getMessage();
+ public String getClassName();
+ /**
+ * The data point representation of the throwable proxy.
+ */
+ public ThrowableDataPoint[] getThrowableDataPointArray();
+ public int getCommonFrames();
+ public IThrowableProxy getCause();
+
+}
\ No newline at end of file
Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java (from r2170, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java Fri Feb 27 17:23:01 2009
@@ -15,40 +15,33 @@
import ch.qos.logback.classic.LoggerContext;
/**
- * LoggerContextRemoteView offers a restricted view of LoggerContext intended to
- * be exposed by LoggingEvent. This restricted view is optimised for
- * serialisation.
+ * LoggerContextVO offers a restricted view of LoggerContext intended to be
+ * exposed by LoggingEvent to remote system. This restricted view is optimized
+ * for serialization.
*
* Some of the LoggerContext or Logger attributes should not survive
* serialization, e.g appenders, level values etc, as these attributes may have
- * other values on the remote platform. LoggerContextRemoteView class exposes
+ * other values on the remote platform. LoggerContextVO class exposes
* the minimal (relevant) attributes to remote host, instead of having to deal
* with an incomplete LoggerContext with many null references.
*
* @author Ceki Gülcü
* @author Sébastien Pennec
*/
-public class LoggerContextRemoteView implements Serializable {
+public class LoggerContextVO implements Serializable {
private static final long serialVersionUID = 5488023392483144387L;
final String name;
final Map<String, String> propertyMap;
final long birthTime;
-
- public LoggerContextRemoteView(LoggerContext lc) {
- // this(lc.getName(), lc.getPropertyMap());
+
+ public LoggerContextVO(LoggerContext lc) {
this.name = lc.getName();
this.propertyMap = lc.getCopyOfPropertyMap();
this.birthTime = lc.getBithTime();
}
- // public LoggerContextRemoteView(String name, Map<String, String>
- // propertyMap) {
- // this.name = name;
- // this.propertyMap = propertyMap;
- // }
-
public String getName() {
return name;
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java Fri Feb 27 17:23:01 2009
@@ -18,7 +18,7 @@
* An interface that allows Logger objects and LoggerSer objects to be used the
* same way be client of the LoggingEvent object.
* <p>
- * See {@link LoggerContextRemoteView} for the rationale of this class.
+ * See {@link LoggerContextVO} for the rationale of this class.
*
* @author Ceki Gülcü
* @author Sébastien Pennec
@@ -27,7 +27,7 @@
private static final long serialVersionUID = 5028223666108713696L;
- final LoggerContextRemoteView loggerContextView;
+ final LoggerContextVO loggerContextView;
final String name;
public LoggerRemoteView(String name, LoggerContext lc) {
@@ -36,7 +36,7 @@
loggerContextView = lc.getLoggerContextRemoteView();
}
- public LoggerContextRemoteView getLoggerContextView() {
+ public LoggerContextVO getLoggerContextView() {
return loggerContextView;
}
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 Fri Feb 27 17:23:01 2009
@@ -20,6 +20,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
/**
* The internal representation of logging events. When an affirmative decision
@@ -50,6 +51,11 @@
*/
private String threadName;
+
+ private String loggerName;
+ private LoggerContextVO loggerContextRemoteView;
+
+
/**
* Level of logging event.
*
@@ -71,7 +77,6 @@
private ThrowableProxy throwableProxy;
private CallerData[] callerDataArray;
- private LoggerRemoteView loggerRemoteView;
private Marker marker;
@@ -89,12 +94,18 @@
public LoggingEvent(String fqcn, Logger logger, Level level, String message,
Throwable throwable, Object[] argArray) {
this.fqnOfLoggerClass = fqcn;
- this.loggerRemoteView = logger.getLoggerRemoteView();
+ this.loggerName = logger.getName();
+ this.loggerContextRemoteView = logger.getLoggerRemoteView().getLoggerContextView();
this.level = level;
+
this.message = message;
if (throwable != null) {
this.throwableProxy = new ThrowableProxy(throwable);
+ LoggerContext lc = logger.getLoggerContext();
+ if(lc.isPackagingDataEnabled()) {
+ this.throwableProxy.calculatePackagingData();
+ }
}
// bug 85 (we previously failed to set this.argumentArray)
@@ -107,7 +118,7 @@
.getMDCAdapter();
mdcPropertyMap = logbackMDCAdapter.getPropertyMap();
}
-
+
public void setArgumentArray(Object[] argArray) {
if (this.argumentArray != null) {
throw new IllegalStateException("argArray has been already set");
@@ -123,6 +134,14 @@
return level;
}
+ public String getLoggerName() {
+ return loggerName;
+ }
+
+ public void setLoggerName(String loggerName) {
+ this.loggerName = loggerName;
+ }
+
public String getThreadName() {
if (threadName == null) {
threadName = (Thread.currentThread()).getName();
@@ -147,7 +166,7 @@
* Returns the throwable information contained within this event. May be
* <code>null</code> if there is no such information.
*/
- public ThrowableProxy getThrowableProxy() {
+ public IThrowableProxy getThrowableProxy() {
return throwableProxy;
}
@@ -178,12 +197,12 @@
}
}
- public LoggerRemoteView getLoggerRemoteView() {
- return loggerRemoteView;
+ public LoggerContextVO getLoggerContextVO() {
+ return loggerContextRemoteView;
}
- public void setLoggerRemoteView(LoggerRemoteView loggerRemoteView) {
- this.loggerRemoteView = loggerRemoteView;
+ public void setLoggerContextRemoteView(LoggerContextVO loggerContextRemoteView) {
+ this.loggerContextRemoteView = loggerContextRemoteView;
}
public String getMessage() {
@@ -248,7 +267,7 @@
}
public long getContextBirthTime() {
- return loggerRemoteView.loggerContextView.getBirthTime();
+ return loggerContextRemoteView.getBirthTime();
}
Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java (from r2171, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventSDO.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventSDO.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java Fri Feb 27 17:23:01 2009
@@ -11,7 +11,9 @@
import ch.qos.logback.classic.Level;
-public class LoggingEventSDO implements ILoggingEvent, Serializable {
+// http://www.riehle.org/computer-science/research/1998/ubilab-tr-1998-10-1.html
+
+public class LoggingEventVO implements ILoggingEvent, Serializable {
private static final long serialVersionUID = 6553722650255690312L;
@@ -19,6 +21,9 @@
private static final String NULL_ARGUMENT_ARRAY_ELEMENT = "NULL_ARGUMENT_ARRAY_ELEMENT";
private String threadName;
+ private String loggerName;
+ private LoggerContextVO loggerContextVO;
+
private transient Level level;
private String message;
@@ -29,16 +34,17 @@
private transient Object[] argumentArray;
- private ThrowableProxy throwableProxy;
+ private ThrowableProxyVO throwableProxy;
private CallerData[] callerDataArray;
private Marker marker;
private Map<String, String> mdcPropertyMap;
- private LoggerRemoteView lrv;
private long timeStamp;
+
- public static LoggingEventSDO build(ILoggingEvent le) {
- LoggingEventSDO ledo = new LoggingEventSDO();
- ledo.lrv = le.getLoggerRemoteView();
+ public static LoggingEventVO build(ILoggingEvent le) {
+ LoggingEventVO ledo = new LoggingEventVO();
+ ledo.loggerName = le.getLoggerName();
+ ledo.loggerContextVO = le.getLoggerContextVO();
ledo.threadName = le.getThreadName();
ledo.level = (le.getLevel());
ledo.message = (le.getMessage());
@@ -46,7 +52,7 @@
ledo.marker = le.getMarker();
ledo.mdcPropertyMap = le.getMDCPropertyMap();
ledo.setTimeStamp(le.getTimeStamp());
- ledo.throwableProxy = le.getThrowableProxy();
+ ledo.throwableProxy = ThrowableProxyVO.build(le.getThrowableProxy());
return ledo;
}
@@ -54,10 +60,18 @@
return threadName;
}
+ public LoggerContextVO getLoggerContextVO() {
+ return loggerContextVO;
+ }
+
+ public String getLoggerName() {
+ return loggerName;
+ }
+
public Level getLevel() {
return level;
}
-
+
public String getMessage() {
return message;
}
@@ -80,7 +94,7 @@
return argumentArray;
}
- public ThrowableProxy getThrowableProxy() {
+ public IThrowableProxy getThrowableProxy() {
return throwableProxy;
}
@@ -100,6 +114,23 @@
this.timeStamp = timeStamp;
}
+
+
+ public long getContextBirthTime() {
+ return loggerContextVO.getBirthTime();
+ }
+
+ public LoggerContextVO getContextLoggerRemoteView() {
+ return loggerContextVO;
+ }
+
+ public Map<String, String> getMDCPropertyMap() {
+ return mdcPropertyMap;
+ }
+
+ public void prepareForDeferredProcessing() {
+ }
+
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeInt(level.levelInt);
@@ -137,21 +168,6 @@
}
}
- public long getContextBirthTime() {
- return lrv.loggerContextView.getBirthTime();
- }
-
- public LoggerRemoteView getLoggerRemoteView() {
- return lrv;
- }
-
- public Map<String, String> getMDCPropertyMap() {
- return mdcPropertyMap;
- }
-
- public void prepareForDeferredProcessing() {
- }
-
@Override
public int hashCode() {
final int prime = 31;
@@ -171,13 +187,20 @@
return false;
if (getClass() != obj.getClass())
return false;
- final LoggingEventSDO other = (LoggingEventSDO) obj;
+ final LoggingEventVO other = (LoggingEventVO) obj;
if (message == null) {
if (other.message != null)
return false;
} else if (!message.equals(other.message))
return false;
+ if (loggerName == null) {
+ if (other.loggerName != null)
+ return false;
+ } else if (!loggerName.equals(other.loggerName))
+ return false;
+
+
if (threadName == null) {
if (other.threadName != null)
return false;
@@ -185,13 +208,13 @@
return false;
if (timeStamp != other.timeStamp)
return false;
-
+
if (marker == null) {
if (other.marker != null)
return false;
} else if (!marker.equals(other.marker))
return false;
-
+
if (mdcPropertyMap == null) {
if (other.mdcPropertyMap != null)
return false;
@@ -199,6 +222,4 @@
return false;
return true;
}
-
-
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java Fri Feb 27 17:23:01 2009
@@ -3,7 +3,7 @@
public class STEUtil {
- static int findNumberOfCommonFrames(StackTraceElement[] steArray,
+ static int UNUSED_findNumberOfCommonFrames(StackTraceElement[] steArray,
StackTraceElement[] otherSTEArray) {
if (otherSTEArray == null) {
return 0;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPoint.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPoint.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPoint.java Fri Feb 27 17:23:01 2009
@@ -31,10 +31,10 @@
StackTraceElementProxy step;
final ThrowableDataPointType type;
- public ThrowableDataPoint(String rawString) {
- this.rawString = rawString;
- this.type = ThrowableDataPointType.RAW;
- }
+// public ThrowableDataPoint(String rawString) {
+// this.rawString = rawString;
+// this.type = ThrowableDataPointType.RAW;
+// }
public ThrowableDataPoint(StackTraceElement ste) {
this.step = new StackTraceElementProxy(ste);
Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPointUtil.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableDataPointUtil.java Fri Feb 27 17:23:01 2009
@@ -0,0 +1,15 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2009, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.classic.spi;
+
+public class ThrowableDataPointUtil {
+
+
+}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java Fri Feb 27 17:23:01 2009
@@ -1,7 +1,7 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
- * Copyright (C) 1999-2005, QOS.ch
+ * Copyright (C) 2000-2009, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -13,22 +13,75 @@
import ch.qos.logback.core.CoreConstants;
-public class ThrowableProxy implements java.io.Serializable {
+public class ThrowableProxy implements IThrowableProxy {
+
+ Throwable throwable;
+ String className;
+ String message;
+ ThrowableDataPoint[] throwableDataPointArray;
+ int commonFrames;
+ ThrowableProxy cause;
- private static final long serialVersionUID = 6307784764626694851L;
- private ThrowableDataPoint[] tdpArray;
- private transient final Throwable throwable;
private transient PackagingDataCalculator packagingDataCalculator;
private boolean calculatedPackageData = false;
-
+
public ThrowableProxy(Throwable throwable) {
+
this.throwable = throwable;
- this.tdpArray = ThrowableToDataPointArray.convert(throwable);
+ this.className = throwable.getClass().getName();
+ this.message = throwable.getMessage();
+ this.throwableDataPointArray = ThrowableProxyUtil.stea2tdpa(throwable
+ .getStackTrace());
+
+ Throwable nested = throwable.getCause();
+
+ if (nested != null) {
+ this.cause = new ThrowableProxy(nested);
+ this.cause.commonFrames = ThrowableProxyUtil
+ .findNumberOfCommonFrames(nested.getStackTrace(),
+ throwableDataPointArray);
+ }
}
+
public Throwable getThrowable() {
return throwable;
- }
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ch.qos.logback.classic.spi.IThrowableProxy#getClassName()
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ch.qos.logback.classic.spi.IThrowableProxy#getThrowableDataPointArray()
+ */
+ public ThrowableDataPoint[] getThrowableDataPointArray() {
+ return throwableDataPointArray;
+ }
+
+ public int getCommonFrames() {
+ return commonFrames;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ch.qos.logback.classic.spi.IThrowableProxy#getCause()
+ */
+ public IThrowableProxy getCause() {
+ return cause;
+ }
public PackagingDataCalculator getPackagingDataCalculator() {
// if original instance (non-deserialized), and packagingDataCalculator
@@ -41,28 +94,21 @@
}
public void calculatePackagingData() {
- if(calculatedPackageData) {
+ if (calculatedPackageData) {
return;
}
PackagingDataCalculator pdc = this.getPackagingDataCalculator();
- if(pdc != null) {
+ if (pdc != null) {
calculatedPackageData = true;
- pdc.calculate(tdpArray);
+ pdc.calculate(throwableDataPointArray);
}
}
-
- /**
- * The data point representation of the throwable proxy.
- */
- public ThrowableDataPoint[] getThrowableDataPointArray() {
- return tdpArray;
- }
@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
- result = PRIME * result + Arrays.hashCode(tdpArray);
+ result = PRIME * result + Arrays.hashCode(throwableDataPointArray);
return result;
}
@@ -75,7 +121,7 @@
if (getClass() != obj.getClass())
return false;
final ThrowableProxy other = (ThrowableProxy) obj;
- if (!Arrays.equals(tdpArray, other.tdpArray))
+ if (!Arrays.equals(throwableDataPointArray, other.throwableDataPointArray))
return false;
return true;
}
@@ -96,10 +142,10 @@
if (step != null) {
ClassPackagingData cpd = step.getClassPackagingData();
if (cpd != null) {
- if(!cpd.isExact()){
- builder.append(" ~[") ;
+ if (!cpd.isExact()) {
+ builder.append(" ~[");
} else {
- builder.append(" [") ;
+ builder.append(" [");
}
builder.append(cpd.getCodeLocation()).append(':').append(
cpd.getVersion()).append(']');
Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java Fri Feb 27 17:23:01 2009
@@ -0,0 +1,108 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2008, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.classic.spi;
+
+import ch.qos.logback.core.CoreConstants;
+
+/**
+ * Convert a throwable into an array of ThrowableDataPoint objects.
+ *
+ *
+ * @author Ceki Gülcü
+ */
+public class ThrowableProxyUtil {
+
+ static final ThrowableDataPoint[] TEMPLATE_ARRAY = new ThrowableDataPoint[0];
+
+ static public void build(ThrowableProxy nestedTP, Throwable nestedThrowable,
+ ThrowableProxy parentTP) {
+
+ StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace();
+
+ int commonFramesCount = -1;
+ if (parentTP != null) {
+ commonFramesCount = findNumberOfCommonFrames(nestedSTE, parentTP
+ .getThrowableDataPointArray());
+ }
+
+ nestedTP.commonFrames = commonFramesCount;
+ nestedTP.throwableDataPointArray = stea2tdpa(nestedSTE);
+ }
+
+ static ThrowableDataPoint[] stea2tdpa(StackTraceElement[] stea) {
+ ThrowableDataPoint[] tdpa = new ThrowableDataPoint[stea.length];
+ for (int i = 0; i < tdpa.length; i++) {
+ tdpa[i] = new ThrowableDataPoint(stea[i]);
+ }
+ return tdpa;
+ }
+
+ static int findNumberOfCommonFrames(StackTraceElement[] steArray,
+ ThrowableDataPoint[] parentTDPA) {
+ if (parentTDPA == null) {
+ return 0;
+ }
+
+ int steIndex = steArray.length - 1;
+ int parentIndex = parentTDPA.length - 1;
+ int count = 0;
+ while (steIndex >= 0 && parentIndex >= 0) {
+ StackTraceElement ste = steArray[steIndex];
+ StackTraceElement otherSte = parentTDPA[parentIndex].step.ste;
+ if (ste.equals(otherSte)) {
+ count++;
+ } else {
+ break;
+ }
+ steIndex--;
+ parentIndex--;
+ }
+ return count;
+ }
+
+ static String asString(IThrowableProxy tp) {
+ StringBuilder sb = new StringBuilder();
+
+ while (tp != null) {
+
+ printFirstLine(sb, tp);
+ printTDP(sb, tp);
+ tp = tp.getCause();
+ }
+ return sb.toString();
+
+ }
+
+ static public void printTDP(StringBuilder sb, IThrowableProxy tp) {
+ ThrowableDataPoint[] tdpa = tp.getThrowableDataPointArray();
+ int commonFrames = tp.getCommonFrames();
+ for (int i = 0; i < tdpa.length - commonFrames; i++) {
+ ThrowableDataPoint tdp = tdpa[i];
+ sb.append(tdp.toString()).append(CoreConstants.LINE_SEPARATOR);
+ }
+
+ if (commonFrames > 0) {
+ sb.append("\t... " + commonFrames).append(" common frames omitted")
+ .append(CoreConstants.LINE_SEPARATOR);
+ }
+
+
+ }
+
+ static public void printFirstLine(StringBuilder sb, IThrowableProxy tp) {
+ int commonFrames = tp.getCommonFrames();
+ if (commonFrames > 0) {
+ sb.append(CoreConstants.CAUSED_BY);
+ }
+ sb.append(tp.getClassName()).append(": ").append(tp.getMessage());
+ sb.append(CoreConstants.LINE_SEPARATOR);
+ }
+}
Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java Fri Feb 27 17:23:01 2009
@@ -0,0 +1,100 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2009, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.classic.spi;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class ThrowableProxyVO implements IThrowableProxy, Serializable {
+
+ private static final long serialVersionUID = 685387990886325422L;
+
+ private String className;
+ private String message;
+ private int commonFramesCount;
+ private ThrowableDataPoint[] throwableDataPointArray;
+ private IThrowableProxy cause;
+
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public int getCommonFrames() {
+ return commonFramesCount;
+ }
+
+ public IThrowableProxy getCause() {
+ return cause;
+ }
+
+ public ThrowableDataPoint[] getThrowableDataPointArray() {
+ return throwableDataPointArray;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((className == null) ? 0 : className.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ThrowableProxyVO other = (ThrowableProxyVO) obj;
+
+ if (className == null) {
+ if (other.className != null)
+ return false;
+ } else if (!className.equals(other.className))
+ return false;
+
+ if (!Arrays.equals(throwableDataPointArray, other.throwableDataPointArray))
+ return false;
+
+ if (cause == null) {
+ if (other.cause != null)
+ return false;
+ } else if (!cause.equals(other.cause))
+ return false;
+
+ return true;
+ }
+
+ public static ThrowableProxyVO build(IThrowableProxy throwableProxy) {
+ if(throwableProxy == null) {
+ return null;
+ }
+ ThrowableProxyVO tpvo = new ThrowableProxyVO();
+ tpvo.className = throwableProxy.getClassName();
+ tpvo.message = throwableProxy.getMessage();
+ tpvo.commonFramesCount = throwableProxy.getCommonFrames();
+ tpvo.throwableDataPointArray = throwableProxy.getThrowableDataPointArray();
+ if(throwableProxy.getCause() != null) {
+ tpvo.cause = ThrowableProxyVO.build(throwableProxy.getCause());
+ }
+ return tpvo;
+ }
+
+
+
+}
Modified: logback/trunk/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original)
+++ logback/trunk/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Fri Feb 27 17:23:01 2009
@@ -17,7 +17,7 @@
import org.slf4j.helpers.Util;
import org.slf4j.spi.LoggerFactoryBinder;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.selector.ContextJNDISelector;
import ch.qos.logback.classic.selector.ContextSelector;
@@ -91,7 +91,7 @@
// See if a special context selector is needed
String contextSelectorStr = OptionHelper
- .getSystemProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR);
+ .getSystemProperty(ClassicConstants.LOGBACK_CONTEXT_SELECTOR);
if (contextSelectorStr == null) {
contextSelector = new DefaultContextSelector(defaultLoggerContext);
} else if (contextSelectorStr.equals("JNDI")) {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java Fri Feb 27 17:23:01 2009
@@ -17,7 +17,7 @@
import org.slf4j.helpers.MarkerIgnoringBase;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
@@ -234,10 +234,10 @@
* @return
*/
HLogger createChildByLastNamePart(final String lastPart) {
- int i_index = lastPart.indexOf(ClassicGlobal.LOGGER_SEPARATOR);
+ int i_index = lastPart.indexOf(ClassicConstants.LOGGER_SEPARATOR);
if (i_index != -1) {
throw new IllegalArgumentException("Child name [" + lastPart
- + " passed as parameter, may not include [" + ClassicGlobal.LOGGER_SEPARATOR
+ + " passed as parameter, may not include [" + ClassicConstants.LOGGER_SEPARATOR
+ "]");
}
@@ -248,7 +248,7 @@
if (this.isRootLogger()) {
childHLogger = new HLogger(lastPart, this);
} else {
- childHLogger = new HLogger(name + ClassicGlobal.LOGGER_SEPARATOR + lastPart,
+ childHLogger = new HLogger(name + ClassicConstants.LOGGER_SEPARATOR + lastPart,
this);
}
childrenMap.put(lastPart, childHLogger);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java Fri Feb 27 17:23:01 2009
@@ -12,7 +12,7 @@
import java.util.HashMap;
import java.util.Map;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
/**
@@ -76,7 +76,7 @@
int i = 0;
while (true) {
- i = name.indexOf(ClassicGlobal.LOGGER_SEPARATOR, i);
+ i = name.indexOf(ClassicConstants.LOGGER_SEPARATOR, i);
if (i == -1) {
// System.out.println("FINAL-Creating logger named [" + name + "] with
// parent " + parent.getName());
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java Fri Feb 27 17:23:01 2009
@@ -11,7 +11,7 @@
import java.util.LinkedList;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
public class ScenarioMaker {
@@ -72,7 +72,7 @@
childName = ScenarioRandomUtil.randomId();
count += childName.length();
} else {
- childName = loggerName + ClassicGlobal.LOGGER_SEPARATOR
+ childName = loggerName + ClassicConstants.LOGGER_SEPARATOR
+ ScenarioRandomUtil.randomId();
count += childName.length();
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java Fri Feb 27 17:23:01 2009
@@ -82,7 +82,7 @@
if (rs.next()) {
assertEquals(event.getTimeStamp(), rs.getLong(1));
assertEquals(event.getFormattedMessage(), rs.getString(2));
- assertEquals(event.getLoggerRemoteView().getName(), rs.getString(3));
+ assertEquals(event.getLoggerName(), rs.getString(3));
assertEquals(event.getLevel().toString(), rs.getString(4));
assertEquals(event.getThreadName(), rs.getString(5));
assertEquals(DBHelper.computeReferenceMask(event), rs.getShort(6));
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java Fri Feb 27 17:23:01 2009
@@ -22,6 +22,7 @@
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.TestConstants;
import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.classic.spi.DummyThrowableProxy;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
@@ -96,15 +97,25 @@
@Test
public void testAppendThrowable() throws Exception {
StringBuilder buf = new StringBuilder();
- ThrowableDataPoint[] strArray = { new ThrowableDataPoint("test1"),
- new ThrowableDataPoint("test2") };
+ DummyThrowableProxy tp = new DummyThrowableProxy();
+ tp.setClassName("test1");
+ tp.setMessage("msg1");
+
+ StackTraceElement ste1 = new StackTraceElement("c1", "m1", "f1", 1);
+ StackTraceElement ste2 = new StackTraceElement("c2", "m2", "f2", 2);
+
+ ThrowableDataPoint[] strArray = { new ThrowableDataPoint(ste1),
+ new ThrowableDataPoint(ste2) };
+ tp.setThrowableDataPointArray(strArray);
DefaultThrowableRenderer renderer = (DefaultThrowableRenderer) layout
.getThrowableRenderer();
- renderer.render(buf, strArray);
- // System.out.println(buf.toString());
+
+ renderer.render(buf, tp);
+ System.out.println(buf.toString());
String[] result = buf.toString().split(CoreConstants.LINE_SEPARATOR);
- assertEquals("<tr><td class=\"Exception\" colspan=\"6\">test1", result[0]);
- assertEquals(DefaultThrowableRenderer.TRACE_PREFIX + "test2", result[1]);
+ System.out.println(result[0]);
+ assertEquals("test1: msg1", result[0]);
+ assertEquals(DefaultThrowableRenderer.TRACE_PREFIX + "\tat c1.m1(f1:1)", result[1]);
}
@Test
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java Fri Feb 27 17:23:01 2009
@@ -9,7 +9,9 @@
*/
package ch.qos.logback.classic.net;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.Map;
@@ -21,9 +23,8 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.LoggerContextRemoteView;
-import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggerContextVO;
import ch.qos.logback.core.read.ListAppender;
import ch.qos.logback.core.util.StatusPrinter;
@@ -32,7 +33,7 @@
static final String LIST_APPENDER_NAME = "la";
static final int JOIN_OR_WAIT_TIMEOUT = 200;
static final int SLEEP_AFTER_LOG = 100;
-
+
int port = 4561;
LoggerContext lc = new LoggerContext();
LoggerContext serverLC = new LoggerContext();
@@ -88,12 +89,12 @@
ILoggingEvent remoteEvent = la.list.get(0);
- LoggerRemoteView loggerRemoteView = remoteEvent.getLoggerRemoteView();
- assertNotNull(loggerRemoteView);
- assertEquals("root", loggerRemoteView.getName());
+ String loggerName = remoteEvent.getLoggerName();
+ assertNotNull(loggerName);
+ assertEquals("root", loggerName);
- LoggerContextRemoteView loggerContextRemoteView = loggerRemoteView
- .getLoggerContextView();
+ LoggerContextVO loggerContextRemoteView = remoteEvent
+ .getLoggerContextVO();
assertNotNull(loggerContextRemoteView);
assertEquals("test", loggerContextRemoteView.getName());
Map<String, String> props = loggerContextRemoteView.getPropertyMap();
@@ -127,8 +128,8 @@
public void messageWithMarker() throws InterruptedException {
fireServer();
waitForServerToStart();
-
- //Thread.sleep(SLEEP_AFTER_SERVER_START);
+
+ // Thread.sleep(SLEEP_AFTER_SERVER_START);
configureClient();
Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
@@ -150,7 +151,7 @@
public void messageWithUpdatedMDC() throws InterruptedException {
fireServer();
waitForServerToStart();
-
+
configureClient();
Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
@@ -185,10 +186,11 @@
fireServer();
waitForServerToStart();
- Thread.sleep(SLEEP_AFTER_LOG); // allow time for client and server to connect
+ Thread.sleep(SLEEP_AFTER_LOG); // allow time for client and server to
+ // connect
logger.debug("test msg 2");
Thread.sleep(SLEEP_AFTER_LOG);
-
+
simpleSocketServer.close();
Thread.sleep(SLEEP_AFTER_LOG);
simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java Fri Feb 27 17:23:01 2009
@@ -37,7 +37,8 @@
// exercise)
le.getFormattedMessage();
le.setLevel(Level.DEBUG);
- le.setLoggerRemoteView(logger.getLoggerRemoteView());
+ le.setLoggerName(logger.getName());
+ le.setLoggerContextRemoteView(logger.getLoggerRemoteView().getLoggerContextView());
le.setThreadName("threadName");
return le;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java Fri Feb 27 17:23:01 2009
@@ -23,7 +23,8 @@
LoggingEvent le = new LoggingEvent();
le.setTimeStamp(System.currentTimeMillis());
le.setLevel(Level.DEBUG);
- le.setLoggerRemoteView(logger.getLoggerRemoteView());
+ le.setLoggerName(logger.getName());
+ le.setLoggerContextRemoteView(logger.getLoggerRemoteView().getLoggerContextView());
le.setMessage(MSG_PREFIX);
le.setThreadName("threadName");
return le;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java Fri Feb 27 17:23:01 2009
@@ -1,3 +1,12 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2009, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
package ch.qos.logback.classic.pattern;
import static org.junit.Assert.assertEquals;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java Fri Feb 27 17:23:01 2009
@@ -16,7 +16,8 @@
@RunWith(Suite.class)
@SuiteClasses( { ConverterTest.class,
TargetLengthBasedClassNameAbbreviatorTest.class, MDCConverterTest.class,
- MarkerConverterTest.class })
+ MarkerConverterTest.class, ExtendedThrowableProxyConverterTest.class,
+ ThrowableProxyConverterTest.class })
public class PackageTest {
}
\ No newline at end of file
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java Fri Feb 27 17:23:01 2009
@@ -8,7 +8,7 @@
import org.slf4j.LoggerFactory;
import org.slf4j.impl.StaticLoggerBinder;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.selector.servlet.ContextDetachingSCL;
import ch.qos.logback.classic.util.MockInitialContext;
import ch.qos.logback.classic.util.MockInitialContextFactory;
@@ -21,14 +21,14 @@
@Before
public void setUp() throws Exception {
- System.setProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, "JNDI");
+ System.setProperty(ClassicConstants.LOGBACK_CONTEXT_SELECTOR, "JNDI");
//LoggerFactory.setup();
listener = new ContextDetachingSCL();
MockInitialContextFactory.initialize();
MockInitialContext mic = MockInitialContextFactory.getContext();
- mic.map.put(ClassicGlobal.JNDI_CONTEXT_NAME, "toto");
+ mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, "toto");
//The property must be set after we setup the Mock
System.setProperty(INITIAL_CONTEXT_KEY, MockInitialContextFactory.class.getName());
@@ -54,11 +54,11 @@
@Test
public void testDetachWithMissingContext() {
MockInitialContext mic = MockInitialContextFactory.getContext();
- mic.map.put(ClassicGlobal.JNDI_CONTEXT_NAME, "tata");
+ mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, "tata");
ContextJNDISelector selector = (ContextJNDISelector) StaticLoggerBinder.getSingleton().getContextSelector();
assertEquals("tata", selector.getLoggerContext().getName());
- mic.map.put(ClassicGlobal.JNDI_CONTEXT_NAME, "titi");
+ mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, "titi");
assertEquals("titi", selector.getLoggerContext().getName());
listener.contextDestroyed(null);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java Fri Feb 27 17:23:01 2009
@@ -9,7 +9,7 @@
import org.slf4j.impl.StaticLoggerBinder;
import org.slf4j.impl.StaticLoggerBinderFriend;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.util.MockInitialContext;
import ch.qos.logback.classic.util.MockInitialContextFactory;
import ch.qos.logback.core.Context;
@@ -21,12 +21,12 @@
@Before
public void setUp() throws Exception {
- System.setProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, "JNDI");
+ System.setProperty(ClassicConstants.LOGBACK_CONTEXT_SELECTOR, "JNDI");
StaticLoggerBinderFriend.reset();
MockInitialContextFactory.initialize();
MockInitialContext mic = MockInitialContextFactory.getContext();
- mic.map.put(ClassicGlobal.JNDI_CONTEXT_NAME, "toto");
+ mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, "toto");
//The property must be set after we setup the Mock
System.setProperty(INITIAL_CONTEXT_KEY, MockInitialContextFactory.class.getName());
@@ -50,7 +50,7 @@
@Test
public void testCreateContext() {
MockInitialContext mic = MockInitialContextFactory.getContext();
- mic.map.put(ClassicGlobal.JNDI_CONTEXT_NAME, "tata");
+ mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, "tata");
LoggerFactory.getLogger(ContextDetachingSCLTest.class);
@@ -64,7 +64,7 @@
@Test
public void defaultContext() {
MockInitialContext mic = MockInitialContextFactory.getContext();
- mic.map.put(ClassicGlobal.JNDI_CONTEXT_NAME, null);
+ mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, null);
ContextJNDISelector selector = (ContextJNDISelector)StaticLoggerBinder.getSingleton().getContextSelector();
Context context = selector.getLoggerContext();
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java Fri Feb 27 17:23:01 2009
@@ -6,6 +6,6 @@
public abstract Throwable getThrowable();
- public abstract ThrowableProxy getThrowableProxy();
+ public abstract IThrowableProxy getThrowableProxy();
}
\ No newline at end of file
Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java Fri Feb 27 17:23:01 2009
@@ -0,0 +1,49 @@
+package ch.qos.logback.classic.spi;
+
+public class DummyThrowableProxy implements IThrowableProxy {
+
+ private String className;
+ private String message;
+ private int commonFramesCount;
+ private ThrowableDataPoint[] throwableDataPointArray;
+ private IThrowableProxy cause;
+
+
+ public String getClassName() {
+ return className;
+ }
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ public int getCommonFrames() {
+ return commonFramesCount;
+ }
+ public void setCommonFramesCount(int commonFramesCount) {
+ this.commonFramesCount = commonFramesCount;
+ }
+
+ public ThrowableDataPoint[] getThrowableDataPointArray() {
+ return throwableDataPointArray;
+ }
+ public void setThrowableDataPointArray(
+ ThrowableDataPoint[] throwableDataPointArray) {
+ this.throwableDataPointArray = throwableDataPointArray;
+ }
+
+ public IThrowableProxy getCause() {
+ return cause;
+ }
+ public void setCause(IThrowableProxy cause) {
+ this.cause = cause;
+ }
+
+
+
+
+}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventExt.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventExt.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventExt.java Fri Feb 27 17:23:01 2009
@@ -82,7 +82,7 @@
private Logger logger;
- private ThrowableProxy throwableInfo;
+ private IThrowableProxy throwableInfo;
private CallerData[] callerDataArray;
@@ -148,14 +148,14 @@
* Returns the throwable information contained within this event. May be
* <code>null</code> if there is no such information.
*/
- public ThrowableProxy getThrowableInformation() {
+ public IThrowableProxy getThrowableInformation() {
return throwableInfo;
}
/**
* Set this event's throwable information.
*/
- public void setThrowableInformation(ThrowableProxy ti) {
+ public void setThrowableInformation(IThrowableProxy ti) {
if (throwableInfo != null) {
throw new IllegalStateException(
"ThrowableInformation has been already set.");
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java Fri Feb 27 17:23:01 2009
@@ -25,8 +25,11 @@
// Using LoggingEventDO
//
// average time per logging event: 4052 nanoseconds
-// size 544'086 bytes
-
+// average size=45, with params, average size=136
+//
+// Using LoggerEventVO, with loggerName, and loggerContextRemoteView
+// average time per logging event: 4034
+// average size 57, with params, average size=148
public class LoggingEventSerializationPerfTest {
@@ -50,8 +53,7 @@
for (int i = 0; i < loopLen; i++) {
try {
ILoggingEvent le = (ILoggingEvent) builder.build(i);
- //oos.writeObject(le);
- oos.writeObject(LoggingEventSDO.build(le));
+ oos.writeObject(LoggingEventVO.build(le));
oos.flush();
if (++resetCounter >= CoreConstants.OOS_RESET_FREQUENCY) {
@@ -78,18 +80,18 @@
noos.reset();
double avg = doLoop(builder, LOOP_LEN); noos.reset();
avg += doLoop(builder, LOOP_LEN); noos.reset();
- avg += doLoop(builder, LOOP_LEN); noos.reset();
+ avg += doLoop(builder, LOOP_LEN);
avg = avg/3;
System.out.println("avetage time per logging event "+avg+" nanoseconds");
- System.out.println("noos size "+noos.size());
- long actualSize = (long) (noos.size()/(1024*1.1d));
- double baosSizeLimit = 500;
+ long averageSize = (long) (noos.size()/(LOOP_LEN));
+ System.out.println("noos size "+noos.size()+ " average size="+averageSize);
+ double averageSizeLimit = 60;
- assertTrue("baos size " + actualSize + " should be less than "
- + baosSizeLimit, baosSizeLimit > actualSize);
+ assertTrue("average size " + averageSize + " should be less than "
+ + averageSizeLimit, averageSizeLimit > averageSize);
// the reference was computed on Orion (Ceki's computer)
long referencePerf = 5000;
@@ -107,12 +109,13 @@
doLoop(builder, LOOP_LEN);
noos.reset();
double avg = doLoop(builder, LOOP_LEN);
+ long averageSize = (long) (noos.size()/(LOOP_LEN));
- long actualSize = (long) (noos.size()/(1024*1.1d));
+ System.out.println("noos size "+noos.size()+ " average size="+averageSize);
- double baosSizeLimit = 1300;
- assertTrue("actualSize " + actualSize + " should be less than "
- + baosSizeLimit, baosSizeLimit > actualSize);
+ double averageSizeLimit = 160;
+ assertTrue("averageSize " + averageSize + " should be less than "
+ + averageSizeLimit, averageSizeLimit > averageSize);
// the reference was computed on Orion (Ceki's computer)
long referencePerf = 7000;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java Fri Feb 27 17:23:01 2009
@@ -64,12 +64,10 @@
ILoggingEvent remoteEvent = writeAndRead(event);
checkForEquality(event, remoteEvent);
- LoggerRemoteView loggerRemoteView = remoteEvent.getLoggerRemoteView();
- assertNotNull(loggerRemoteView);
- assertEquals("root", loggerRemoteView.getName());
+ assertNotNull(remoteEvent.getLoggerName());
+ assertEquals("root", remoteEvent.getLoggerName());
- LoggerContextRemoteView loggerContextRemoteView = loggerRemoteView
- .getLoggerContextView();
+ LoggerContextVO loggerContextRemoteView = remoteEvent.getLoggerContextVO();
assertNotNull(loggerContextRemoteView);
assertEquals("testContext", loggerContextRemoteView.getName());
Map<String, String> props = loggerContextRemoteView.getPropertyMap();
@@ -120,7 +118,7 @@
event.setArgumentArray(new Object[] { lucky0, null });
ILoggingEvent remoteEvent = writeAndRead(event);
checkForEquality(event, remoteEvent);
-
+
Object[] aa = remoteEvent.getArgumentArray();
assertNotNull(aa);
assertEquals(2, aa.length);
@@ -149,22 +147,20 @@
ILoggingEvent remoteEvent = writeAndRead(event);
checkForEquality(event, remoteEvent);
}
-
-
+
@Test
public void serializeLargeArgs() throws Exception {
-
+
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 100000; i++) {
buffer.append("X");
}
String largeString = buffer.toString();
- Object[] argArray = new Object[] {new LuckyCharms(2),
- largeString };
-
+ Object[] argArray = new Object[] { new LuckyCharms(2), largeString };
+
LoggingEvent event = createLoggingEvent();
event.setArgumentArray(argArray);
-
+
ILoggingEvent remoteEvent = writeAndRead(event);
checkForEquality(event, remoteEvent);
Object[] aa = remoteEvent.getArgumentArray();
@@ -186,11 +182,12 @@
assertEquals(original.getFormattedMessage(), afterSerialization
.getFormattedMessage());
assertEquals(original.getMessage(), afterSerialization.getMessage());
-
+
System.out.println();
-
- assertEquals(original.getThrowableProxy(), afterSerialization
+
+ ThrowableProxyVO witness = ThrowableProxyVO.build(original
.getThrowableProxy());
+ assertEquals(witness, afterSerialization.getThrowableProxy());
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java Fri Feb 27 17:23:01 2009
@@ -16,7 +16,7 @@
@RunWith(Suite.class)
@SuiteClasses( { ContextListenerTest.class, CallerDataTest.class,
LoggerComparatorTest.class, LoggingEventSerializationTest.class,
- LoggingEventSerializationPerfTest.class, ThrowableToDataPointTest.class,
+ LoggingEventSerializationPerfTest.class, ThrowableProxyTest.class,
BasicCPDCTest.class })
public class PackageTest {
}
\ No newline at end of file
Copied: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java (from r2131, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java)
==============================================================================
--- /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java Fri Feb 27 17:23:01 2009
@@ -9,9 +9,7 @@
import org.junit.Before;
import org.junit.Test;
-import ch.qos.logback.core.CoreConstants;
-
-public class ThrowableToDataPointTest {
+public class ThrowableProxyTest {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -26,19 +24,23 @@
public void verify(Throwable t) {
t.printStackTrace(pw);
+
+ IThrowableProxy tp = new ThrowableProxy(t);
- ThrowableDataPoint[] tdpArray = ThrowableToDataPointArray.convert(t);
- StringBuilder sb = new StringBuilder();
- for (ThrowableDataPoint tdp : tdpArray) {
- sb.append(tdp.toString());
- sb.append(CoreConstants.LINE_SEPARATOR);
- }
+ String result = ThrowableProxyUtil.asString(tp);
+ result = result.replace("common frames omitted", "more");
+
String expected = sw.toString();
- String result = sb.toString().replace("common frames omitted", "more");
+ System.out.println("========expected");
+ System.out.println(expected);
+
+ System.out.println("========result");
+ System.out.println(result);
+
assertEquals(expected, result);
}
-
+
@Test
public void smoke() {
Exception e = new Exception("smoke");
@@ -66,7 +68,7 @@
}
verify(w);
}
-
+
void someMethod() throws Exception {
throw new Exception("someMethod");
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java Fri Feb 27 17:23:01 2009
@@ -1,6 +1,7 @@
package ch.qos.logback.classic.spi.special;
import ch.qos.logback.classic.spi.CPDCSpecial;
+import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.PackagingDataCalculator;
import ch.qos.logback.classic.spi.ThrowableProxy;
@@ -9,7 +10,7 @@
Throwable throwable;
- ThrowableProxy throwableProxy;
+ IThrowableProxy throwableProxy;
public void doTest() {
nesting();
@@ -25,7 +26,7 @@
public Throwable getThrowable() {
return throwable;
}
- public ThrowableProxy getThrowableProxy() {
+ public IThrowableProxy getThrowableProxy() {
return throwableProxy;
}
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java Fri Feb 27 17:23:01 2009
@@ -6,7 +6,7 @@
import org.slf4j.MDC;
import org.slf4j.Marker;
-import ch.qos.logback.classic.ClassicGlobal;
+import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.core.spi.FilterReply;
@@ -31,7 +31,7 @@
if (!level.equals(Level.DEBUG)) {
return FilterReply.NEUTRAL;
}
- String user = MDC.get(ClassicGlobal.USER_MDC_KEY);
+ String user = MDC.get(ClassicConstants.USER_MDC_KEY);
if (user != null && userList.contains(user)) {
return FilterReply.ACCEPT;
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java Fri Feb 27 17:23:01 2009
@@ -10,8 +10,8 @@
package ch.qos.logback.core.html;
-public interface IThrowableRenderer {
+public interface IThrowableRenderer<E> {
- public void render(StringBuilder sbuf, Object event);
+ public void render(StringBuilder sbuf, E event);
}
Modified: logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java (original)
+++ logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java Fri Feb 27 17:23:01 2009
@@ -8,13 +8,13 @@
public String doLayout(ILoggingEvent event) {
StringBuffer sbuf = new StringBuffer(128);
- sbuf.append(event.getTimeStamp() - event.getContextBirthTime());
+ sbuf.append(event.getTimeStamp() - event.getLoggerContextVO().getBirthTime());
sbuf.append(" ");
sbuf.append(event.getLevel());
sbuf.append(" [");
sbuf.append(event.getThreadName());
sbuf.append("] ");
- sbuf.append(event.getLoggerRemoteView().getName());
+ sbuf.append(event.getLoggerName());
sbuf.append(" - ");
sbuf.append(event.getFormattedMessage());
sbuf.append(CoreConstants.LINE_SEPARATOR);
Modified: logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java (original)
+++ logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java Fri Feb 27 17:23:01 2009
@@ -22,7 +22,7 @@
if (prefix != null) {
sbuf.append(prefix + ": ");
}
- sbuf.append(event.getTimeStamp() - event.getContextBirthTime());
+ sbuf.append(event.getTimeStamp() - event.getLoggerContextVO().getBirthTime());
sbuf.append(" ");
sbuf.append(event.getLevel());
if (printThreadName) {
@@ -32,7 +32,7 @@
} else {
sbuf.append(" ");
}
- sbuf.append(event.getLoggerRemoteView().getName());
+ sbuf.append(event.getLoggerName());
sbuf.append(" - ");
sbuf.append(event.getFormattedMessage());
sbuf.append(CoreConstants.LINE_SEPARATOR);
Modified: logback/trunk/logback-site/src/site/pages/news.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/news.html (original)
+++ logback/trunk/logback-site/src/site/pages/news.html Fri Feb 27 17:23:01 2009
@@ -40,6 +40,14 @@
a message</a> to the logback-user list
</p>
+ <p>If the logger name had 12 or more segments, a the logger
+ conversion specified would throw an
+ <code>ArrayIndexOfBounds</code> exception. Lukas Zapletal has
+ kindly reported this problem in <a
+ href="http://jira.qos.ch/browse/LBCLASSIC-110">LBCLASSIC-110</a>
+ and provided a test case.
+ </p>
+
<hr width="80%" align="center" />
<h3>12th of February 2009 - Release of version 0.9.15</h3>
More information about the logback-dev
mailing list