branch, master, updated. 12f248fab183df513aa84c1147f8781b69d3a18d

The branch, master has been updated via 12f248fab183df513aa84c1147f8781b69d3a18d (commit) from 21b667f88d347ecacf1cb3ef60d159a3eba71d89 (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=12f248fab183df513aa84c114... http://github.com/ceki/logback/commit/12f248fab183df513aa84c1147f8781b69d3a1... commit 12f248fab183df513aa84c1147f8781b69d3a18d Author: Ceki Gulcu <ceki@qos.ch> Date: Wed Dec 2 14:33:41 2009 +0100 - the check for the timestamp of the existing log file was missing hence the reapperance of LBCORE-26. Some tests still fail. Ongoing work. diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java b/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java index b1add24..81ea93e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java @@ -20,8 +20,6 @@ import java.util.Map; import org.slf4j.helpers.MarkerIgnoringBase; -import ch.qos.logback.classic.ClassicConstants; -import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; import ch.qos.logback.core.CoreConstants; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java index 17eabe8..d4069f1 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java @@ -34,7 +34,6 @@ import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase; import ch.qos.logback.core.boolex.Matcher; import ch.qos.logback.core.filter.EvaluatorFilter; import ch.qos.logback.core.spi.FilterReply; -import ch.qos.logback.core.util.StatusPrinter; public class JaninoEventEvaluatorTest { diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java b/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java index 651af43..9f86dc5 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java @@ -16,7 +16,6 @@ package ch.qos.logback.classic.control; import java.util.HashMap; import java.util.Map; -import ch.qos.logback.classic.ClassicConstants; import ch.qos.logback.classic.Level; import ch.qos.logback.core.CoreConstants; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java b/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java index ead333b..c5cc0e7 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java @@ -15,7 +15,6 @@ package ch.qos.logback.classic.control; import java.util.LinkedList; -import ch.qos.logback.classic.ClassicConstants; import ch.qos.logback.classic.Level; import ch.qos.logback.core.CoreConstants; diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java index 8c5a761..3d25940 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java @@ -40,7 +40,7 @@ public class DefaultTimeBasedFileNamingAndTriggeringPolicy<E> extends TimeBasedF Date dateOfElapsedPeriod = dateInCurrentPeriod; elapsedPeriodsFileName = tbrp.fileNamePatternWCS .convert(dateOfElapsedPeriod); - updateDateInCurrentPeriod(time); + setDateInCurrentPeriod(time); computeNextCheck(); return true; } else { diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java index 02cc66a..7e7206c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java @@ -77,7 +77,7 @@ public class SizeAndTimeBasedFNATP<E> extends elapsedPeriodsFileName = tbrp.fileNamePatternWCS .convertMultipleArguments(dateInElapsedPeriod, currentPeriodsCounter); currentPeriodsCounter = 0; - updateDateInCurrentPeriod(time); + setDateInCurrentPeriod(time); computeNextCheck(); return true; } diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java index 20f2e52..fbdd13c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java @@ -13,8 +13,6 @@ */ package ch.qos.logback.core.rolling; -import java.util.Date; - import ch.qos.logback.core.rolling.helper.ArchiveRemover; import ch.qos.logback.core.spi.ContextAware; @@ -77,7 +75,10 @@ public interface TimeBasedFileNamingAndTriggeringPolicy<E> extends * Set some date in the current period. Only unit tests should invoke this * method. * + * WARNING: method removed. A unit test should not set the + * date in current period. It is the job of the FNATP to compute that. + * * @param date */ - void setDateInCurrentPeriod(Date date); + //void setDateInCurrentPeriod(Date date); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java index 4587f8c..b7f5fd8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java @@ -13,6 +13,7 @@ */ package ch.qos.logback.core.rolling; +import java.io.File; import java.util.Date; import ch.qos.logback.core.rolling.helper.ArchiveRemover; @@ -20,25 +21,23 @@ import ch.qos.logback.core.rolling.helper.DateTokenConverter; import ch.qos.logback.core.rolling.helper.RollingCalendar; import ch.qos.logback.core.spi.ContextAwareBase; -abstract public class TimeBasedFileNamingAndTriggeringPolicyBase<E> extends ContextAwareBase - implements TimeBasedFileNamingAndTriggeringPolicy<E> { +abstract public class TimeBasedFileNamingAndTriggeringPolicyBase<E> extends + ContextAwareBase implements TimeBasedFileNamingAndTriggeringPolicy<E> { protected TimeBasedRollingPolicy<E> tbrp; - + protected ArchiveRemover archiveRemover = null; protected String elapsedPeriodsFileName; protected RollingCalendar rc; - - + protected long currentTime; - //indicate whether the time has been forced or not + // indicate whether the time has been forced or not protected boolean isTimeForced = false; protected Date dateInCurrentPeriod = null; - + protected long nextCheck; protected boolean started = false; - public boolean isStarted() { return started; } @@ -58,23 +57,32 @@ abstract public class TimeBasedFileNamingAndTriggeringPolicyBase<E> extends Cont + "'."); rc.printPeriodicity(this); - // dateInCurrentPeriod can be set by test classes - // if it has not been set, we set it here + if (dateInCurrentPeriod == null) { - dateInCurrentPeriod = new Date(); - updateDateInCurrentPeriod(getCurrentTime()); + setDateInCurrentPeriod(new Date(getCurrentTime())); + + if (tbrp.getParentsRawFileProperty() != null) { + File currentFile = new File(tbrp.getParentsRawFileProperty()); + if (currentFile.exists() && currentFile.canRead()) { + setDateInCurrentPeriod(new Date(currentFile.lastModified())); + } + } } computeNextCheck(); } - + public void stop() { started = false; } - + protected void computeNextCheck() { nextCheck = rc.getNextTriggeringMillis(dateInCurrentPeriod); } + protected void setDateInCurrentPeriod(long now) { + dateInCurrentPeriod.setTime(now); + } + // allow Test classes to act on the dateInCurrentPeriod field to simulate old // log files needing rollover public void setDateInCurrentPeriod(Date _dateInCurrentPeriod) { @@ -93,11 +101,6 @@ abstract public class TimeBasedFileNamingAndTriggeringPolicyBase<E> extends Cont return tbrp.fileNamePatternWCS.convert(dateInCurrentPeriod); } - - protected void updateDateInCurrentPeriod(long now) { - dateInCurrentPeriod.setTime(now); - } - public void setCurrentTime(long timeInMillis) { currentTime = timeInMillis; isTimeForced = true; @@ -111,7 +114,7 @@ abstract public class TimeBasedFileNamingAndTriggeringPolicyBase<E> extends Cont return System.currentTimeMillis(); } } - + public void setTimeBasedRollingPolicy(TimeBasedRollingPolicy<E> _tbrp) { this.tbrp = _tbrp; diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java index 989585e..ee228d4 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java @@ -60,9 +60,9 @@ public class SizeAndTimeBasedFNATP_Test extends tbrp.setFileNamePattern(filenamePattern); tbrp.setParent(rfa); tbrp.timeBasedTriggering.setCurrentTime(givenTime); - if (lastCheck != 0) { - tbrp.timeBasedTriggering.setDateInCurrentPeriod(new Date(lastCheck)); - } +// if (lastCheck != 0) { +// tbrp.timeBasedTriggering.setDateInCurrentPeriod(new Date(lastCheck)); +// } rfa.setRollingPolicy(tbrp); tbrp.start(); rfa.start(); diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java index 30b5c9c..5276ae2 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java @@ -15,6 +15,7 @@ package ch.qos.logback.core.rolling; import static org.junit.Assert.assertTrue; +import java.io.File; import java.sql.Date; import java.util.concurrent.TimeUnit; @@ -75,15 +76,12 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { } void initTRBP(RollingFileAppender<Object> rfa, TimeBasedRollingPolicy<Object> tbrp, - String filenamePattern, long givenTime, long lastCheck) { + String filenamePattern, long givenTime) { tbrp.setContext(context); tbrp.setFileNamePattern(filenamePattern); tbrp.setParent(rfa); tbrp.timeBasedTriggering = new DefaultTimeBasedFileNamingAndTriggeringPolicy<Object>(); tbrp.timeBasedTriggering.setCurrentTime(givenTime); - if (lastCheck != 0) { - tbrp.timeBasedTriggering.setDateInCurrentPeriod(new Date(lastCheck)); - } rfa.setRollingPolicy(tbrp); tbrp.start(); rfa.start(); @@ -97,7 +95,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { String testId = "test1"; initRFA(rfa1, null); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); // compute the current filename addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false); @@ -127,7 +125,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { String testId = "test2"; initRFA(rfa1, null); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime); addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true); incCurrentTime(1100); @@ -160,7 +158,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { initRFA(rfa1, null); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); // a new file is created by virtue of rfa.start(); addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false); @@ -179,7 +177,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { initRFA(rfa2, null); initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", tbrp1.timeBasedTriggering.getCurrentTime(), 0); + + DATE_PATTERN_WITH_SECONDS + "}", tbrp1.timeBasedTriggering.getCurrentTime()); for (int i = 0; i <= 2; i++) { addExpectedFileNamedIfItsTime_ByDate(testId, false); @@ -203,7 +201,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { String testId = "test4"; initRFA(rfa1, testId2FileName(testId)); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false); @@ -217,11 +215,16 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { tbrp1.timeBasedTriggering.setCurrentTime(currentTime); } + File activeFile = new File(rfa1.getFile()); + + System.out.println("activeFile="+activeFile); + activeFile.setLastModified(currentTime); rfa1.stop(); + initRFA(rfa2, testId2FileName(testId)); initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, currentTime); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); for (int i = 0; i <= 2; i++) { rfa2.doAppend("World---" + i); @@ -245,7 +248,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { String testId = "test4B"; initRFA(rfa1, testId2FileName(testId)); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false); @@ -264,12 +267,15 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { System.out.println("time before wait "+SDF.format(new Date(currentTime))); - long fileTimestamp = currentTime; + File activeFile = new File(rfa1.getFile()); + activeFile.setLastModified(currentTime); + + incCurrentTime(2000); initRFA(rfa2, randomOutputDir + "test4B.log"); initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, fileTimestamp); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); System.out.println("time after wait "+SDF.format(new Date(currentTime))); for (int i = 0; i <= 2; i++) { @@ -298,7 +304,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { initRFA(rfa1, testId2FileName(testId)); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}", currentTime); addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false); @@ -331,7 +337,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { initRFA(rfa1, testId2FileName(testId)); initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{" - + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime, 0); + + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime); addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true); diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java index 1387f12..679afed 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java @@ -15,6 +15,7 @@ package ch.qos.logback.core.rolling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.FileFilter; import java.util.ArrayList; @@ -37,7 +38,6 @@ import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.layout.EchoLayout; import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.util.CoreTestConstants; -import ch.qos.logback.core.util.StatusPrinter; public class TimeBasedRollingWithArchiveRemovalTest { ----------------------------------------------------------------------- Summary of changes: .../test/java/ch/qos/logback/classic/HLogger.java | 2 - .../classic/boolex/JaninoEventEvaluatorTest.java | 1 - .../classic/control/ControlLoggerContext.java | 1 - .../qos/logback/classic/control/ScenarioMaker.java | 1 - ...aultTimeBasedFileNamingAndTriggeringPolicy.java | 2 +- .../core/rolling/SizeAndTimeBasedFNATP.java | 2 +- .../TimeBasedFileNamingAndTriggeringPolicy.java | 7 ++- ...TimeBasedFileNamingAndTriggeringPolicyBase.java | 43 ++++++++++--------- .../core/rolling/SizeAndTimeBasedFNATP_Test.java | 6 +- .../logback/core/rolling/TimeBasedRollingTest.java | 36 ++++++++++------- .../TimeBasedRollingWithArchiveRemovalTest.java | 2 +- 11 files changed, 54 insertions(+), 49 deletions(-) hooks/post-receive -- Logback: the generic, reliable, fast and flexible logging framework.
participants (1)
-
git-noreply@pixie.qos.ch