[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-64-gf28496a
Gitbot
git-noreply at pixie.qos.ch
Mon Oct 31 21:41:55 CET 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 f28496ad3e5c631876c5e777c1bb54df88969476 (commit)
from 1b3439a5868d50b8423f675e15dc8db9a35b7102 (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=f28496ad3e5c631876c5e777c1bb54df88969476
http://github.com/ceki/logback/commit/f28496ad3e5c631876c5e777c1bb54df88969476
commit f28496ad3e5c631876c5e777c1bb54df88969476
Author: Ceki Gulcu <ceki at qos.ch>
Date: Mon Oct 31 21:41:19 2011 +0100
added timeOfLastReset method to StatusChecker
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
index 19f8aa1..9d78f8e 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
@@ -19,6 +19,7 @@ import java.util.List;
import ch.qos.logback.classic.gaffer.GafferUtil;
import ch.qos.logback.classic.util.EnvUtil;
+import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.joran.event.SaxEvent;
import ch.qos.logback.core.joran.spi.ConfigurationWatchList;
import ch.qos.logback.core.joran.util.ConfigurationWatchListUtil;
@@ -39,9 +40,6 @@ import ch.qos.logback.core.spi.FilterReply;
*/
public class ReconfigureOnChangeFilter extends TurboFilter {
- final static long INIT = System.currentTimeMillis();
- final static long SENTINEL = Long.MAX_VALUE;
-
/**
* Scan for changes in configuration file once every minute.
*/
@@ -153,7 +151,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
return;
}
LoggerContext lc = (LoggerContext) context;
- addInfo("Will reset and reconfigure context named [" + context.getName() + "]");
+ addInfo(CoreConstants.RESET_MSG_PREFIX + "named ["+context.getName() + "]");
if (mainConfigurationURL.toString().endsWith("xml")) {
performXMLConfiguration(lc);
} else if (mainConfigurationURL.toString().endsWith("groovy")) {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
index b4c1e74..22db069 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
@@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.LogManager;
import ch.qos.logback.classic.jul.JULHelper;
+import ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter;
import ch.qos.logback.core.pattern.parser.Parser;
import ch.qos.logback.core.pattern.parser.ScanException;
import ch.qos.logback.core.status.Status;
@@ -308,7 +309,7 @@ public class JoranConfiguratorTest {
//StatusPrinter.print(loggerContext);
StatusChecker checker = new StatusChecker(loggerContext);
assertTrue(checker.isErrorFree(0));
- assertTrue(checker.containsMatch("Will reset and reconfigure context"));
+ assertTrue(checker.containsMatch(CoreConstants.RESET_MSG_PREFIX));
}
@Test
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
index 3884672..d451b1b 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
@@ -260,7 +260,7 @@ public class ReconfigureOnChangeTest {
}
int effectiveResets = checker
- .matchCount("Will reset and reconfigure context");
+ .matchCount(CoreConstants.RESET_MSG_PREFIX);
String failMsg = "effective=" + effectiveResets + ", expected="
+ expected;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
index fcb642f..55fb8e4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
@@ -82,7 +82,6 @@ public class CoreConstants {
public static final char DOUBLE_QUOTE_CHAR = '"';
public static final char SINGLE_QUOTE_CHAR = '\'';
-
/**
* Number of rows before in an HTML table before,
* we close the table and create a new one
@@ -140,4 +139,6 @@ public class CoreConstants {
public static final int MILLIS_IN_ONE_WEEK = MILLIS_IN_ONE_DAY*7;
public static final String CONTEXT_SCOPE_VALUE = "context";
+
+ final public static String RESET_MSG_PREFIX = "Will reset and reconfigure context ";
}
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 d9e3d2c..ae61c74 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
@@ -116,4 +116,22 @@ public class StatusChecker {
return false;
}
+ /**
+ * Return the time of last reset. -1 if last reset time could not be found
+ * @return time of last reset or -1
+ */
+ public long timeOfLastReset() {
+ List<Status> statusList = sm.getCopyOfStatusList();
+ if(statusList == null)
+ return -1;
+
+ int len = statusList.size();
+ for(int i = len-1; i >= 0; i--) {
+ Status s = statusList.get(i);
+ if(CoreConstants.RESET_MSG_PREFIX.equals(s.getMessage())) {
+ return s.getDate();
+ }
+ }
+ return -1;
+ }
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/status/StatusCheckerTest.java b/logback-core/src/test/java/ch/qos/logback/core/status/StatusCheckerTest.java
new file mode 100644
index 0000000..695edb2
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/status/StatusCheckerTest.java
@@ -0,0 +1,40 @@
+package ch.qos.logback.core.status;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.CoreConstants;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Ceki Gücü
+ */
+public class StatusCheckerTest {
+
+ Context context = new ContextBase();
+ StatusChecker checker = new StatusChecker(context);
+
+ @Test
+ public void emptyStatusListShouldResultInNotFound() {
+ assertEquals(-1, checker.timeOfLastReset());
+ }
+
+ @Test
+ public void withoutResetsCheckerShouldReturnNotFound() {
+ context.getStatusManager().add(new InfoStatus("test", this));
+ assertEquals(-1, checker.timeOfLastReset());
+ }
+
+ @Test
+ public void statusListShouldReturnLastResetTime() {
+ context.getStatusManager().add(new InfoStatus("test", this));
+ long resetTime = System.currentTimeMillis();
+ context.getStatusManager().add(new InfoStatus(CoreConstants.RESET_MSG_PREFIX, this));
+ context.getStatusManager().add(new InfoStatus("bla", this));
+ assertTrue(resetTime <= checker.timeOfLastReset());
+ }
+
+
+}
-----------------------------------------------------------------------
Summary of changes:
.../classic/turbo/ReconfigureOnChangeFilter.java | 6 +--
.../classic/joran/JoranConfiguratorTest.java | 3 +-
.../classic/turbo/ReconfigureOnChangeTest.java | 2 +-
.../java/ch/qos/logback/core/CoreConstants.java | 3 +-
.../ch/qos/logback/core/status/StatusChecker.java | 18 +++++++++
.../qos/logback/core/status/StatusCheckerTest.java | 40 ++++++++++++++++++++
6 files changed, 65 insertions(+), 7 deletions(-)
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/status/StatusCheckerTest.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list