[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.29-10-g6e98d1b

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Fri Jul 1 18:39:32 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  6e98d1bb0c1c728aafaf64846207603b0f482946 (commit)
      from  187647c5d3552e665cf365cf0fdfdf4023227b02 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=6e98d1bb0c1c728aafaf64846207603b0f482946
http://github.com/ceki/logback/commit/6e98d1bb0c1c728aafaf64846207603b0f482946

commit 6e98d1bb0c1c728aafaf64846207603b0f482946
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Fri Jul 1 18:31:23 2011 +0200

    fixing LBCLASSIC-273

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
index b0e0693..1dae9d6 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
@@ -208,10 +208,13 @@ public class LoggerContext extends ContextBase implements ILoggerFactory,
   }
 
   /**
-   * This method clears all internal properties, closes all appenders, removes
-   * any turboFilters, fires an OnReset event, removes all status listeners,
-   * removes all context listeners (except those which are reset resistant).
-   */
+   * This method clears all internal properties, except internal status messages,
+   * closes all appenders, removes any turboFilters, fires an OnReset event,
+   * removes all status listeners, removes all context listeners
+   * (except those which are reset resistant).
+   * <p>
+   * As mentioned above, internal status messages survive resets.
+   * */
   @Override
   public void reset() {
     resetCount++;
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
index 11fa9c5..6369585 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
@@ -30,10 +30,11 @@ public class ConfigurationAction extends Action {
   static final String SCAN_PERIOD_ATTR = "scanPeriod";
 
   boolean debugMode = false;
+  long threshold = 0;
 
   public void begin(InterpretationContext ec, String name, Attributes attributes) {
     String debugAttrib = ec.subst(attributes.getValue(INTERNAL_DEBUG_ATTR));
-
+    threshold = System.currentTimeMillis();
     if (OptionHelper.isEmpty(debugAttrib)
         || debugAttrib.equalsIgnoreCase("false")
         || debugAttrib.equalsIgnoreCase("null")) {
@@ -79,7 +80,7 @@ public class ConfigurationAction extends Action {
     if (debugMode) {
       addInfo("End of configuration.");
       LoggerContext loggerContext = (LoggerContext) context;
-      StatusPrinter.print(loggerContext);
+      StatusPrinter.print(loggerContext, threshold);
     }
     ec.popObject();
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java
index cf12305..18f81cc 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java
@@ -13,7 +13,6 @@
  */
 package ch.qos.logback.core.status;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -22,6 +21,8 @@ import java.util.regex.Pattern;
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.CoreConstants;
 
+import static ch.qos.logback.core.status.StatusUtil.filterStatusListByTimeThreshold;
+
 public class StatusChecker {
 
   StatusManager sm;
@@ -34,18 +35,10 @@ public class StatusChecker {
     this.sm = context.getStatusManager();
   }
 
-  private List<Status> filterStatusListByTimeThreshold(List<Status> rawList, long threshold) {
-    List<Status> filteredList = new ArrayList<Status>();
-    for (Status s : rawList) {
-      if (s.getDate() >= threshold)
-        filteredList.add(s);
-    }
-    return filteredList;
-  }
-
   public boolean hasXMLParsingErrors(long threshold) {
     return containsMatch(threshold, Status.ERROR, CoreConstants.XML_PARSING);
   }
+
   public boolean noXMLParsingErrorsOccurred(long threshold) {
     return !hasXMLParsingErrors(threshold);
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java
index d246c8b..c57daad 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java
@@ -15,8 +15,20 @@ package ch.qos.logback.core.status;
 
 import ch.qos.logback.core.Context;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class StatusUtil {
 
+  static public List<Status> filterStatusListByTimeThreshold(List<Status> rawList, long threshold) {
+    List<Status> filteredList = new ArrayList<Status>();
+    for (Status s : rawList) {
+      if (s.getDate() >= threshold)
+        filteredList.add(s);
+    }
+    return filteredList;
+  }
+
   static public void addStatus(Context context, Status status) {
     if (context == null) {
       return;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java b/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java
index 40394cd..2794a22 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java
@@ -25,6 +25,8 @@ import ch.qos.logback.core.status.Status;
 import ch.qos.logback.core.status.StatusChecker;
 import ch.qos.logback.core.status.StatusManager;
 
+import static ch.qos.logback.core.status.StatusUtil.filterStatusListByTimeThreshold;
+
 public class StatusPrinter {
 
   private static PrintStream ps = System.out;
@@ -88,26 +90,39 @@ public class StatusPrinter {
    * @param context
    */
   public static void print(Context context) {
-    if (context == null) {
-      throw new IllegalArgumentException("Context argument cannot be null");
-    }
+    print(context, 0);
+  }
 
-    StatusManager sm = context.getStatusManager();
-    if (sm == null) {
-      ps.println("WARN: Context named \"" + context.getName()
-          + "\" has no status manager");
-    } else {
-      print(sm);
-    }
+   /**
+   * Print context's status data with a timestamp higher than the threshold.
+   * @param context
+   */
+   public static void print(Context context, long threshold) {
+     if (context == null) {
+       throw new IllegalArgumentException("Context argument cannot be null");
+     }
+
+     StatusManager sm = context.getStatusManager();
+     if (sm == null) {
+       ps.println("WARN: Context named \"" + context.getName()
+           + "\" has no status manager");
+     } else {
+       print(sm, threshold);
+     }
+   }
 
+  public static void print(StatusManager sm) {
+    print(sm, 0);
   }
 
-  public static void print(StatusManager sm) {
+  public static void print(StatusManager sm, long threshold) {
     StringBuilder sb = new StringBuilder();
-    buildStrFromStatusManager(sb, sm);
+    List<Status> filteredList = filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
+    buildStrFromStatusList(sb, filteredList);
     ps.println(sb.toString());
   }
 
+
   public static void print(List<Status> statusList) {
     StringBuilder sb = new StringBuilder();
     buildStrFromStatusList(sb, statusList);
@@ -123,9 +138,9 @@ public class StatusPrinter {
     }
   }
 
-  private static void buildStrFromStatusManager(StringBuilder sb, StatusManager sm) {
-    buildStrFromStatusList(sb, sm.getCopyOfStatusList());
-  }
+//  private static void buildStrFromStatusManager(StringBuilder sb, StatusManager sm) {
+//  }
+
   
   private static void appendThrowable(StringBuilder sb, Throwable t) {
     String[] stringRep = ThrowableToStringArray.convert(t);
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index dedf41c..da477fd 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -42,6 +42,16 @@
     class="option">to</span> properties are suported.
     </p>
 
+    <p>When debug attribute is set to true within
+    <code>&lt;the></code> configuration element, status messages are
+    printed on the console after Joran (re)configures
+    logback. Previously, all status messages were printed. With this
+    release, only status messages created during (re)configuration are
+    printed. This change fixes <a
+    href="http://jira.qos.ch/browse/LBCLASSIC-273">/LBCLASSIC-273</a>
+    reported by Joern Huxhorn.
+    </p>
+
     <hr width="80%" align="center" />
 
     <h3>June 9th, 2011 - Release of version 0.9.29</h3>

-----------------------------------------------------------------------

Summary of changes:
 .../java/ch/qos/logback/classic/LoggerContext.java |   11 +++--
 .../classic/joran/action/ConfigurationAction.java  |    5 +-
 .../ch/qos/logback/core/status/StatusChecker.java  |   13 +----
 .../ch/qos/logback/core/status/StatusUtil.java     |   12 +++++
 .../ch/qos/logback/core/util/StatusPrinter.java    |   45 +++++++++++++-------
 logback-site/src/site/pages/news.html              |   10 ++++
 6 files changed, 65 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list