[logback-dev] svn commit: r2115 - in logback/trunk/logback-core/src/main/java/ch/qos/logback/core: . status

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Dec 30 11:20:20 CET 2008


Author: ceki
Date: Tue Dec 30 11:20:19 2008
New Revision: 2115

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java

Log:
- allow clearing of the status list. This addresses LBCORE-77

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java	Tue Dec 30 11:20:19 2008
@@ -20,7 +20,7 @@
 public class BasicStatusManager implements StatusManager {
 
   public static final int MAX_HEADER_COUNT = 150;
-  public static final int TAIL_SIZE = 150; 
+  public static final int TAIL_SIZE = 150;
 
   int count = 0;
 
@@ -67,6 +67,7 @@
     }
 
   }
+
   public List<Status> getCopyOfStatusList() {
     synchronized (statusListLock) {
       List<Status> tList = new ArrayList<Status>(statusList);
@@ -74,7 +75,7 @@
       return tList;
     }
   }
-  
+
   private void fireStatusAddEvent(Status status) {
     synchronized (statusListenerListLock) {
       for (StatusListener sl : statusListenerList) {
@@ -83,6 +84,14 @@
     }
   }
 
+  public void clear() {
+    synchronized (statusListLock) {
+      count = 0;
+      statusList.clear();
+      tailBuffer.clear();
+    }
+  }
+
   public int getLevel() {
     return level;
   }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java	Tue Dec 30 11:20:19 2008
@@ -12,20 +12,29 @@
 import ch.qos.logback.core.spi.PropertyContainer;
 import ch.qos.logback.core.status.StatusManager;
 
-
+/**
+ * A context is the main anchorage point of all logback components.
+ * 
+ * @author Ceki Gulcu
+ * 
+ */
 public interface Context extends PropertyContainer {
 
-	
-  StatusManager getStatusManager();
-  
   /**
-   * A Context can act as a store for various objects used
-   * by LOGBack components.
+   * Return the StatusManager instance in use.
+   * 
+   * @return the {@link StatusManager} instance in use.
+   */
+  public StatusManager getStatusManager();
+
+  /**
+   * A Context can act as a store for various objects used by LOGBack
+   * components.
    * 
    * @return The object stored under 'key'.
    */
   public Object getObject(String key);
- 
+
   /**
    * Store an object under 'key'. If no object can be found, null is returned.
    * 
@@ -33,34 +42,35 @@
    * @param value
    */
   public void putObject(String key, Object value);
-  
+
   /**
-   * Get all the properties for this context as a Map. Note that
-   * the returned cop might be a copy not the original. Thus, modifying
-   * the returned Map will have no effect (on the original.)
+   * Get all the properties for this context as a Map. Note that the returned
+   * cop might be a copy not the original. Thus, modifying the returned Map will
+   * have no effect (on the original.)
+   * 
    * @return
    */
-  //public Map<String, String> getPropertyMap();
-
-  /** 
+  // public Map<String, String> getPropertyMap();
+  /**
    * Get the property of this context.
    */
   public String getProperty(String key);
 
-  /** 
+  /**
    * Set a property of this context.
    */
   public void putProperty(String key, String value);
-  
+
   /**
    * Contexts are named objects.
    * 
    * @return the name for this context
    */
   public String getName();
-  
+
   /**
    * The name of the context can be set only once.
+   * 
    * @param name
    */
   public void setName(String name);

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java	Tue Dec 30 11:20:19 2008
@@ -46,10 +46,26 @@
    */
   public int getCount();
 
+  /**
+   * Add a status listener.
+   * @param listener
+   */
   public void add(StatusListener listener);
-
+  
+  /**
+   * Remove a status listener.
+   * 
+   * @param listener
+   */
   public void remove(StatusListener listener);
 
+
+  /**
+   * Clear the list of status messages.
+   */
+  public void clear();
+
+  
   /**
    * Obtain a copy of the status listener list maintained by this StatusManager
    * 


More information about the logback-dev mailing list