[LOGBack-dev] svn commit: r518 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic main/java/ch/qos/logback/classic/boolex main/java/ch/qos/logback/classic/net main/java/ch/qos/logback/classic/pattern main/java/ch/qos/logback/classic/spi main/java/ch/qos/logback/classic/util test/java/ch/qos/logback/classic test/java/ch/qos/logback/classic/boolex test/java/ch/qos/logback/classic/net test/java/ch/qos/logback/classic/net/testObjectBuilders test/java/ch/qos/logback/classic/pattern

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Sep 7 13:56:08 CEST 2006


Author: seb
Date: Thu Sep  7 13:56:07 2006
New Revision: 518

Added:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java
      - copied, changed from r515, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextView.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java
      - copied, changed from r516, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerView.java
Removed:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextSer.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextView.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerSer.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerView.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/net/SocketNode.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.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/spi/LoggingEvent.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.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/SocketMin.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java

Log:

- removed Logger*Ser classes in favor of moving their implementation into Logger*RemoteView
- LoggerContext now notifies its loggers about changes in its name.
- We still need to notify about changes inLC's propertyMap field
- updated test to reflect changes

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	Thu Sep  7 13:56:07 2006
@@ -25,7 +25,7 @@
 import ch.qos.logback.core.spi.AppenderAttachableImpl;
 
 
-public final class Logger implements org.slf4j.Logger, LoggerView, AppenderAttachable, Serializable {
+public final class Logger implements org.slf4j.Logger, AppenderAttachable, Serializable {
 
   /**
 	 * 
@@ -75,11 +75,15 @@
   private boolean additive = true;
 
   final transient LoggerContext loggerContext;
-
+  // loggerRemoteView cannot be final because it may change as a consequence
+  // of changes in LoggerContext
+  LoggerRemoteView loggerRemoteView;
+  
   Logger(String name, Logger parent, LoggerContext loggerContext) {
     this.name = name;
     this.parent = parent;
     this.loggerContext = loggerContext;
+    buildRemoteView();
     instanceCount++;
   }
 
@@ -688,15 +692,16 @@
    * Return the context for this logger.
    * @return
    */
-	public LoggerContextView getLoggerContext() {
+	public LoggerContext getLoggerContext() {
 		return loggerContext;
 	}
+
+	
+	public LoggerRemoteView getLoggerRemoteView() {
+		return loggerRemoteView;
+	}
 	
-	public LoggerSer getLoggerSer() {
-		LoggerSer loggerSer = new LoggerSer();
-		loggerSer.level = level;
-		loggerSer.name = name;
-		loggerSer.loggerContext = loggerContext.getLoggerContextSer();
-		return loggerSer;
+	void buildRemoteView() {
+	  this.loggerRemoteView = new LoggerRemoteView(name, loggerContext);
 	}
 }

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	Thu Sep  7 13:56:07 2006
@@ -23,7 +23,7 @@
 /**
  * @author ceki
  */
-public class LoggerContext extends ContextBase implements ILoggerFactory, LoggerContextView {
+public class LoggerContext extends ContextBase implements ILoggerFactory {
 
 	public static final String ROOT_NAME = "root";
 	
@@ -36,19 +36,40 @@
   // cost of a very slightly higher memory footprint.
   private Hashtable<String, Logger> loggerCache;
 
-  
+	LoggerContextRemoteView loggerContextRemoteView;
+	
   public LoggerContext() {
     super();
-    this.root = new Logger("root", null, this);
-    this.root.setLevel(Level.DEBUG);
     this.loggerCache = new Hashtable<String, Logger>();
-    size = 1;
+    this.loggerContextRemoteView = new LoggerContextRemoteView(getName(), getPropertyMap());
+    this.root = new Logger(ROOT_NAME, null, this);
+    this.root.setLevel(Level.DEBUG);
+    loggerCache.put(ROOT_NAME, root);
     putObject(CoreGlobal.EVALUATOR_MAP, new HashMap());
+    size = 1;
+  }
+  
+  /**
+   * A new instance of LoggerContextRemoteView needs to be created each time
+   * the name or propertyMap (including keys or values) changes.
+   */
+  private void syncRemoteView() {
+  	loggerContextRemoteView = new LoggerContextRemoteView(getName(), getPropertyMap());
+  	for(Logger logger : loggerCache.values()) {
+  		logger.buildRemoteView();
+  	}
+  }
+  
+  @Override
+  public void setName(String name) {
+	  	super.setName(name);
+	    syncRemoteView();
   }
 
   public final Logger getLogger(final Class clazz) {
     return getLogger(clazz.getName());
   }
+  
   public final Logger getLogger(final String name) {
 
     //if we are asking for the root logger, then let us return it without wasting time
@@ -59,12 +80,16 @@
     int i = 0;
     Logger logger = root;
     
+    // check if the desired logger exists, if it does, return it
+    // without further ado.
     Logger childLogger = (Logger) loggerCache.get(name);
     // if we have the child, then let us return it without wasting time
     if (childLogger != null) {
       return childLogger;
     }
 
+    // if the desired logger does not exist, them create all the loggers
+    // in between as well (if they don't already exist)
     String childName;
     while (true) {
       int h = name.indexOf('.', i);
@@ -115,10 +140,7 @@
   	 }
   }
   
-  public LoggerContextSer getLoggerContextSer() {
-  	LoggerContextSer loggerContextSer = new LoggerContextSer();
-  	loggerContextSer.name = this.getName();
-  	loggerContextSer.propertyMap = this.getPropertyMap();
-  	return loggerContextSer;
+  public LoggerContextRemoteView getLoggerContextRemoteView() {
+  	return loggerContextRemoteView;
   }
 }

Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java (from r515, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextView.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextView.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java	Thu Sep  7 13:56:07 2006
@@ -1,9 +1,38 @@
 package ch.qos.logback.classic;
 
+import java.io.Serializable;
 import java.util.Map;
 
-public interface LoggerContextView {
+/**
+ * LoggerContextRemoteView offers a restricted view of LoggerContext intended to be 
+ * exposed by LoggingEvent. This restricted view is optimiyed for serialisation.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ * @author S&eacute;bastien Pennec
+ */
+public class LoggerContextRemoteView implements Serializable {
+
+	
+	private static final long serialVersionUID = 5488023392483144387L;
+
+	final String name;
+	final Map<String, String> propertyMap;
+
+	
+	public LoggerContextRemoteView(LoggerContext lc) {
+		this(lc.getName(), lc.getPropertyMap());
+	}
+	
+	public LoggerContextRemoteView(String name, Map<String, String> propertyMap) {
+		this.name = name;
+		this.propertyMap = propertyMap;
+	}
+	
+	public String getName() {
+		return name;
+	}
+	public Map<String, String> getPropertyMap() {
+		return propertyMap;
+	}
 
-	public String getName();
-	public Map<String, String> getPropertyMap();
 }

Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java (from r516, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerView.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerView.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java	Thu Sep  7 13:56:07 2006
@@ -10,17 +10,37 @@
 
 package ch.qos.logback.classic;
 
+import java.io.Serializable;
+
 /**
  * An interface that allows Logger objects and LoggerSer objects to be used the
  * same way be client of the LoggingEvent object.
- * 
+ *
+ * @author Ceki G&uuml;lc&uuml;
  * @author S&eacute;bastien Pennec
  */
-public interface LoggerView {
+public class LoggerRemoteView implements Serializable {
+
+
+	private static final long serialVersionUID = 5028223666108713696L;
+
+	final LoggerContextRemoteView loggerContextView;
+	final String name;
+
+	LoggerRemoteView(String name, LoggerContext lc) {
+		this.name = name;
+		assert lc.getLoggerContextRemoteView() != null;
+		loggerContextView = lc.getLoggerContextRemoteView();
+	}
+	
+	
+	public LoggerContextRemoteView getLoggerContextView() {
+		return loggerContextView;
+	}
 
-	public String getName();
+	public String getName() {
+		return name;
+	}
 
-	public LoggerContextView getLoggerContext();
 
-	public LoggerSer getLoggerSer();
 }

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	Thu Sep  7 13:56:07 2006
@@ -6,7 +6,7 @@
 import org.slf4j.Marker;
 
 import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerRemoteView;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.core.CoreGlobal;
 import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
@@ -44,7 +44,7 @@
     
     DEFAULT_PARAM_TYPE_LIST.add(LoggingEvent.class);
     DEFAULT_PARAM_TYPE_LIST.add(String.class);
-    DEFAULT_PARAM_TYPE_LIST.add(Logger.class);
+    DEFAULT_PARAM_TYPE_LIST.add(LoggerRemoteView.class);
     DEFAULT_PARAM_TYPE_LIST.add(int.class);
     DEFAULT_PARAM_TYPE_LIST.add(long.class);
     DEFAULT_PARAM_TYPE_LIST.add(Marker.class);
@@ -89,7 +89,7 @@
     
     values[i++] = loggingEvent;
     values[i++] = loggingEvent.getMessage();    
-    values[i++] = loggingEvent.getLogger();
+    values[i++] = loggingEvent.getLoggerRemoteView();
     values[i++] = loggingEvent.getLevel().toInteger();
     values[i++] = new Long(loggingEvent.getTimeStamp());
     values[i++] = loggingEvent.getMarker();

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	Thu Sep  7 13:56:07 2006
@@ -72,7 +72,7 @@
 				event = (LoggingEvent) 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.getLogger().getName());
+				remoteLogger = context.getLogger(event.getLoggerRemoteView().getName());
 				// 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/pattern/CallerDataConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.java	Thu Sep  7 13:56:07 2006
@@ -29,7 +29,7 @@
 public class CallerDataConverter extends ClassicConverter {
 
   int depth = 5;
-  List<EventEvaluator> evaluatorList;
+  List<EventEvaluator> evaluatorList = null;
 
   public void start() {
     String depthStr = getFirstOption();

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	Thu Sep  7 13:56:07 2006
@@ -14,6 +14,6 @@
 public class LoggerConverter extends NamedConverter {
 
   protected String getFullyQualifiedName(LoggingEvent event) {
-    return event.getLogger().getName();
+    return event.getLoggerRemoteView().getName();
   }
 }

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	Thu Sep  7 13:56:07 2006
@@ -15,12 +15,13 @@
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 
-import org.slf4j.Logger;
 import org.slf4j.Marker;
 import org.slf4j.impl.MessageFormatter;
 
+
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerView;
+import ch.qos.logback.classic.LoggerRemoteView;
 
 /**
  * The internal representation of logging events. When an affirmative decision
@@ -80,12 +81,11 @@
 
 	private Object[] argumentArray;
 
-	private transient LoggerView logger;
-
-	private transient ThrowableInformation throwableInfo;
-
-	private transient CallerData[] callerDataArray;
+	private ThrowableInformation throwableInfo;
 
+	private CallerData[] callerDataArray;
+	private LoggerRemoteView loggerRemoteView;
+	
 	private Marker marker;
 
 	/**
@@ -100,7 +100,7 @@
 	public LoggingEvent(String fqcn, Logger logger, Level level, String message,
 			Throwable throwable, Object[] argArray) {
 		this.fqnOfLoggerClass = fqcn;
-		this.logger = (ch.qos.logback.classic.Logger)logger;
+		this.loggerRemoteView = logger.getLoggerRemoteView();
 		this.level = level;
 		this.message = message;
 
@@ -179,12 +179,12 @@
 		this.getThreadName();
 	}
 
-	public LoggerView getLogger() {
-		return logger;
+	public LoggerRemoteView getLoggerRemoteView() {
+		return loggerRemoteView;
 	}
 
-	public void setLogger(LoggerView logger) {
-		this.logger = logger;
+	public void setLoggerRemoteView(LoggerRemoteView loggerRemoteView) {
+		this.loggerRemoteView = loggerRemoteView;
 	}
 
 	public String getMessage() {
@@ -266,7 +266,8 @@
 
 	private void writeObject(ObjectOutputStream out) throws IOException {
 		out.defaultWriteObject();
-		out.writeObject(logger.getLoggerSer());
+		//out.writeObject(loggerView);
+		
 		out.writeInt(level.levelInt);
 	}
 
@@ -275,7 +276,7 @@
 		in.defaultReadObject();
 		//String loggerName = (String) in.readObject();
 		//logger = LoggerFactory.getLogger(loggerName);
-		logger = (LoggerView)in.readObject();
+		//loggerView = (LoggerView)in.readObject();
 		int levelInt = in.readInt();
 		level = Level.toLevel(levelInt);
 	}

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java	Thu Sep  7 13:56:07 2006
@@ -12,7 +12,7 @@
 	
 	public static void printStatusInDefaultContext() {
 		Logger logger = (Logger)LoggerFactory.getLogger(LoggerStatusPrinter.class);
-		LoggerContext lc = (LoggerContext)logger.getLoggerContext();
+		LoggerContext lc = logger.getLoggerContext();
 		StatusManager sm = lc.getStatusManager();
     StatusPrinter.print(sm);
 	}

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	Thu Sep  7 13:56:07 2006
@@ -59,7 +59,7 @@
   
   public void testRootLogger() {
   	Logger logger = (Logger)LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
-  	LoggerContext lc = (LoggerContext)logger.getLoggerContext();
+  	LoggerContext lc = logger.getLoggerContext();
 		
   	assertNotNull("Returned logger is null", logger);
   	assertEquals("Return logger isn't named root", logger.getName(), LoggerContext.ROOT_NAME);

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java	Thu Sep  7 13:56:07 2006
@@ -18,6 +18,7 @@
   protected void setUp() throws Exception {
    Logger.instanceCount = 0;
    lc = new LoggerContext();
+   lc.setName("x");
   }
 
   public void testRootGetLogger()  {

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	Thu Sep  7 13:56:07 2006
@@ -15,9 +15,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.PatternLayout;
@@ -30,7 +28,8 @@
 
 public class PatternLayoutTest extends AbstractPatternLayoutBaseTest {
 
-  Logger logger = LoggerFactory.getLogger(ConverterTest.class);
+	LoggerContext lc = new LoggerContext();
+  Logger logger = lc.getLogger(ConverterTest.class);
   LoggingEvent le;
   List optionList = new ArrayList();
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java	Thu Sep  7 13:56:07 2006
@@ -2,9 +2,9 @@
 
 import junit.framework.TestCase;
 
-import org.slf4j.Logger;
 import org.slf4j.MarkerFactory;
 
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.boolex.JaninoEventEvaluator;

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java	Thu Sep  7 13:56:07 2006
@@ -5,14 +5,9 @@
 import java.net.Socket;
 
 import junit.framework.TestCase;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.net.testObjectBuilders.Builder;
-import ch.qos.logback.classic.net.testObjectBuilders.LoggingEventExtBuilder;
 import ch.qos.logback.classic.net.testObjectBuilders.LoggingEventBuilder;
-import ch.qos.logback.classic.net.testObjectBuilders.MinimalExtBuilder;
 import ch.qos.logback.classic.net.testObjectBuilders.MinimalSerBuilder;
-import ch.qos.logback.classic.spi.LoggingEvent;
 
 public class SerializationPerfsTest extends TestCase {
 

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	Thu Sep  7 13:56:07 2006
@@ -5,8 +5,8 @@
 import junit.framework.TestCase;
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.LoggerContextSer;
-import ch.qos.logback.classic.LoggerSer;
+import ch.qos.logback.classic.LoggerContextRemoteView;
+import ch.qos.logback.classic.LoggerRemoteView;
 import ch.qos.logback.classic.spi.LoggingEvent;
 
 public class SocketAppenderTest extends TestCase {
@@ -28,7 +28,7 @@
 		// client configuration
 		LoggerContext lc = new LoggerContext();
 		lc.setName("test");
-		lc.getPropertyMap().put("testKey", "testValue");
+		lc.setProperty("testKey", "testValue");
 		Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
 		SocketAppender socketAppender = new SocketAppender();
 		socketAppender.setContext(lc);
@@ -39,7 +39,7 @@
 		socketAppender.start();
 				
 		Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
-		logger.debug("test");
+		logger.debug("test msg");
 
     // Wait max 2 seconds for mock server to finish. However, it should
     // finish much sooner than that.		
@@ -47,11 +47,15 @@
 		assertTrue(mockServer.finished);
 		assertEquals(1, mockServer.loggingEventList.size());
 		LoggingEvent remoteEvent = mockServer.loggingEventList.get(0);
-		LoggerSer loggerSer = (LoggerSer)remoteEvent.getLogger();
-		LoggerContextSer loggerContextSer = (LoggerContextSer)loggerSer.getLoggerContext();
-		assertEquals("test", loggerContextSer.getName());
-		assertEquals("root", loggerSer.getName());
-		Map<String, String> props = loggerContextSer.getPropertyMap();
+		LoggerRemoteView loggerRemoteView = remoteEvent.getLoggerRemoteView();
+		assertEquals("test msg", remoteEvent.getMessage());
+		assertNotNull(loggerRemoteView);
+		assertEquals("root", loggerRemoteView.getName());
+
+		LoggerContextRemoteView loggerContextRemoteView = loggerRemoteView.getLoggerContextView();
+		assertNotNull(loggerContextRemoteView);
+		assertEquals("test", loggerContextRemoteView.getName());
+		Map<String, String> props = loggerContextRemoteView.getPropertyMap();
 		assertEquals("testValue", props.get("testKey"));
 	}
 }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java	Thu Sep  7 13:56:07 2006
@@ -50,7 +50,7 @@
 
 	static void init(String host, String portStr) {
 		Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
-		BasicConfigurator.configure((LoggerContext)root.getLoggerContext());
+		BasicConfigurator.configure(root.getLoggerContext());
 		try {
 			int port = Integer.parseInt(portStr);
 			logger.info("Creating socket appender (" + host + "," + port + ").");

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java	Thu Sep  7 13:56:07 2006
@@ -12,7 +12,7 @@
 	public Object build(int i) {
 		LoggingEvent le = new LoggingEvent();
 		le.setLevel(Level.DEBUG);
-		le.setLogger(logger);
+		le.setLoggerRemoteView(logger.getLoggerRemoteView());
 		//le.setLogger(new LoggerContext().getLogger(LoggerContext.ROOT_NAME));
 		le.setMessage(MSG_PREFIX + i);
 		le.setThreadName("threadName");

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java	Thu Sep  7 13:56:07 2006
@@ -14,11 +14,11 @@
 
 import junit.framework.TestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.slf4j.MarkerFactory;
 
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.core.CoreGlobal;
 import ch.qos.logback.core.net.SyslogConstants;
@@ -28,7 +28,8 @@
 
 public class ConverterTest extends TestCase {
 
-  Logger logger = LoggerFactory.getLogger(ConverterTest.class);
+	LoggerContext lc = new LoggerContext();
+  Logger logger = lc.getLogger(ConverterTest.class);
   LoggingEvent le;
   List<String> optionList = new ArrayList<String>();
 
@@ -71,7 +72,7 @@
       StringBuffer buf = new StringBuffer();
       converter.write(buf, le);
       // the number below should be the line number of the previous line
-      assertEquals("72", buf.toString());
+      assertEquals("73", buf.toString());
     }
   }
 



More information about the logback-dev mailing list