[logback-dev] svn commit: r678 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Oct 13 17:53:20 CEST 2006


Author: seb
Date: Fri Oct 13 17:53:20 2006
New Revision: 678

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/ThrowableInformationConverter.java

Log:
- CallerDataConverter.java and ThrowableInformationConverter.java error count added and corrected.

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	Fri Oct 13 17:53:20 2006
@@ -19,6 +19,7 @@
 import ch.qos.logback.core.CoreGlobal;
 import ch.qos.logback.core.boolex.EvaluationException;
 import ch.qos.logback.core.boolex.EventEvaluator;
+import ch.qos.logback.core.status.ErrorStatus;
 
 
 /**
@@ -31,6 +32,9 @@
   int depth = 5;
   List<EventEvaluator> evaluatorList = null;
 
+  final int MAX_ERROR_COUNT = 4;
+  int errorCount = 0;
+  
   public void start() {
     String depthStr = getFirstOption();
     if (depthStr == null) {
@@ -84,7 +88,19 @@
             break;
           }
         } catch (EvaluationException eex) {
-          // just ignore evaluation exception
+          errorCount++;
+          if (errorCount < MAX_ERROR_COUNT) {
+            addError("Exception thrown for evaluator named [" + ee.getName()
+                + "]", eex);
+          } else if (errorCount == MAX_ERROR_COUNT) {
+            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));
+            addStatus(errorStatus);
+          }
+
         }
       }
 

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableInformationConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableInformationConverter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableInformationConverter.java	Fri Oct 13 17:53:20 2006
@@ -10,7 +10,7 @@
 import ch.qos.logback.core.CoreGlobal;
 import ch.qos.logback.core.boolex.EvaluationException;
 import ch.qos.logback.core.boolex.EventEvaluator;
-
+import ch.qos.logback.core.status.ErrorStatus;
 
 /**
  * Add a stack trace i case the event contains a Throwable.
@@ -21,10 +21,9 @@
 
   int lengthOption;
   List<EventEvaluator> evaluatorList = null;
-  
-  final int MAX_ERROR_COUNT = 2;
+
+  final int MAX_ERROR_COUNT = 4;
   int errorCount = 0;
-  
 
   public void start() {
 
@@ -43,7 +42,7 @@
           // we add one because, printing starts at offset 1
           lengthOption = Integer.parseInt(lengthStr) + 1;
         } catch (NumberFormatException nfe) {
-          addError("Could not parser ["+lengthStr+" as an integer");
+          addError("Could not parser [" + lengthStr + " as an integer");
           lengthOption = Integer.MAX_VALUE;
         }
       }
@@ -88,7 +87,8 @@
 
     String[] stringRep = information.getThrowableStrRep();
 
-    int length =  (lengthOption > stringRep.length) ? stringRep.length : lengthOption;
+    int length = (lengthOption > stringRep.length) ? stringRep.length
+        : lengthOption;
 
     if (evaluatorList != null) {
       boolean printStack = true;
@@ -100,8 +100,17 @@
             break;
           }
         } catch (EvaluationException eex) {
-          if (++errorCount <= MAX_ERROR_COUNT) {
-            addError("Exception thrown for evaluator named ["+ee.getName()+"]", eex);
+          errorCount++;
+          if (errorCount < MAX_ERROR_COUNT) {
+            addError("Exception thrown for evaluator named [" + ee.getName()
+                + "]", eex);
+          } else if (errorCount == MAX_ERROR_COUNT) {
+            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));
+            addStatus(errorStatus);
           }
         }
       }



More information about the logback-dev mailing list