use of io.questdb.std.datetime.microtime.MicrosecondClock in project questdb by bluestreak01.
the class LogFactoryTest method testRollingFileWriterDateParsePushFilesMid.
@Test
public void testRollingFileWriterDateParsePushFilesMid() throws Exception {
String base = temp.getRoot().getAbsolutePath() + Files.SEPARATOR;
String expectedLogFile = base + "mylog-2015-05-03.log";
try (LogFactory factory = new LogFactory()) {
String logFile = base + "mylog-${date:yyyy-MM-dd}.log";
final MicrosecondClock clock = new TestMicrosecondClock(TimestampFormatUtils.parseTimestamp("2015-05-03T10:35:00.000Z"), 1);
try (Path path = new Path()) {
path.of(base);
Assert.assertTrue(Files.touch(path.concat("mylog-2015-05-03.log").$()));
path.of(base);
Assert.assertTrue(Files.touch(path.concat("mylog-2015-05-03.log.1").$()));
path.of(base);
Assert.assertTrue(Files.touch(path.concat("mylog-2015-05-03.log.2").$()));
// there is a gap here, .3 is available
path.of(base);
Assert.assertTrue(Files.touch(path.concat("mylog-2015-05-03.log.4").$()));
}
factory.add(new LogWriterConfig(LogLevel.LOG_LEVEL_INFO, (ring, seq, level) -> {
LogRollingFileWriter w = new LogRollingFileWriter(FilesFacadeImpl.INSTANCE, clock, ring, seq, level);
w.setLocation(logFile);
w.setSpinBeforeFlush("1000000");
return w;
}));
factory.bind();
factory.startThread();
try {
Log logger = factory.create("x");
for (int i = 0; i < 100000; i++) {
logger.xinfo().$("test ").$(' ').$(i).$();
}
Os.sleep(1000);
} finally {
factory.haltThread();
}
}
Assert.assertTrue(new File(expectedLogFile).length() > 0);
}
Aggregations