use of io.dropwizard.logging.layout.DropwizardLayoutFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method appenderNameIsSet.
@Test
void appenderNameIsSet(@TempDir Path tempDir) {
final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
final FileAppenderFactory<ILoggingEvent> appenderFactory = new FileAppenderFactory<>();
appenderFactory.setArchivedLogFilenamePattern(tempDir.resolve("example-%d.log.gz").toString());
Appender<ILoggingEvent> appender = null;
try {
appender = appenderFactory.build(root.getLoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(appender.getName()).isEqualTo("async-file-appender");
} finally {
if (appender != null) {
appender.stop();
}
}
}
use of io.dropwizard.logging.layout.DropwizardLayoutFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method includesCallerData.
@Test
void includesCallerData() {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
assertThat(fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory())).isInstanceOfSatisfying(AsyncAppender.class, asyncAppender -> assertThat(asyncAppender.isIncludeCallerData()).isFalse());
fileAppenderFactory.setIncludeCallerData(true);
assertThat(fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory())).isInstanceOfSatisfying(AsyncAppender.class, asyncAppender -> assertThat(asyncAppender.isIncludeCallerData()).isTrue());
}
use of io.dropwizard.logging.layout.DropwizardLayoutFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isNeverBlock.
@Test
void isNeverBlock() {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
fileAppenderFactory.setNeverBlock(true);
assertThat(fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory())).isInstanceOfSatisfying(AsyncAppender.class, asyncAppender -> assertThat(asyncAppender.isNeverBlock()).isTrue());
}
use of io.dropwizard.logging.layout.DropwizardLayoutFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isImmediateFlushed.
@Test
void isImmediateFlushed() throws Exception {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
Field isImmediateFlushField = OutputStreamAppender.class.getDeclaredField("immediateFlush");
isImmediateFlushField.setAccessible(true);
fileAppenderFactory.setImmediateFlush(false);
assertThat(fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory())).isInstanceOfSatisfying(AsyncAppender.class, asyncAppender -> assertThat(asyncAppender).extracting(appender -> appender.getAppender("file-appender")).satisfies(fileAppender -> assertThat(isImmediateFlushField.get(fileAppender)).isEqualTo(fileAppenderFactory.isImmediateFlush())));
fileAppenderFactory.setImmediateFlush(true);
assertThat(fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory())).isInstanceOfSatisfying(AsyncAppender.class, asyncAppender -> assertThat(asyncAppender).extracting(appender -> appender.getAppender("file-appender")).satisfies(fileAppender -> assertThat(isImmediateFlushField.get(fileAppender)).isEqualTo(fileAppenderFactory.isImmediateFlush())));
}
use of io.dropwizard.logging.layout.DropwizardLayoutFactory in project dropwizard by dropwizard.
the class SyslogAppenderFactoryTest method appenderNameIsSet.
@Test
void appenderNameIsSet() {
final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
final SyslogAppenderFactory appenderFactory = new SyslogAppenderFactory();
final Appender<ILoggingEvent> appender = appenderFactory.build(root.getLoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(appender.getName()).isEqualTo("async-syslog-appender");
}
Aggregations