use of io.quarkus.runtime.logging.LogConfig in project quarkus by quarkusio.
the class ConfigInstantiatorTestCase method handleLogConfig.
@Test
public void handleLogConfig() {
LogConfig logConfig = new LogConfig();
ConfigInstantiator.handleObject(logConfig);
assertThat(logConfig.level).isEqualTo(Level.INFO);
assertThat(logConfig.categories).hasSize(2);
// note: category assertions are a bit awkward because most fields and classes are just package visible
// (level.level selects the actual level member of InheritableLevel.ActualLevel)
assertThat(logConfig.categories.get("foo.bar")).hasFieldOrPropertyWithValue("level.level", Level.DEBUG);
assertThat(logConfig.categories.get("baz")).hasFieldOrPropertyWithValue("level.level", Level.TRACE);
}
use of io.quarkus.runtime.logging.LogConfig in project quarkus by quarkusio.
the class LoggingResourceProcessor method setupLoggingRuntimeInit.
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
LoggingSetupBuildItem setupLoggingRuntimeInit(LoggingSetupRecorder recorder, LogConfig log, LogBuildTimeConfig buildLog, Optional<WebSocketLogHandlerBuildItem> logStreamHandlerBuildItem, List<LogHandlerBuildItem> handlerBuildItems, List<NamedLogHandlersBuildItem> namedHandlerBuildItems, List<LogConsoleFormatBuildItem> consoleFormatItems, Optional<ConsoleFormatterBannerBuildItem> possibleBannerBuildItem, List<LogStreamBuildItem> logStreamBuildItems, LaunchModeBuildItem launchModeBuildItem, List<LogCleanupFilterBuildItem> logCleanupFilters) {
if (!launchModeBuildItem.isAuxiliaryApplication() || launchModeBuildItem.getAuxiliaryDevModeType().orElse(null) == DevModeType.TEST_ONLY) {
final List<RuntimeValue<Optional<Handler>>> handlers = handlerBuildItems.stream().map(LogHandlerBuildItem::getHandlerValue).collect(Collectors.toList());
final List<RuntimeValue<Map<String, Handler>>> namedHandlers = namedHandlerBuildItems.stream().map(NamedLogHandlersBuildItem::getNamedHandlersMap).collect(Collectors.toList());
ConsoleFormatterBannerBuildItem bannerBuildItem = null;
RuntimeValue<Optional<Supplier<String>>> possibleSupplier = null;
if (possibleBannerBuildItem.isPresent()) {
bannerBuildItem = possibleBannerBuildItem.get();
}
if (bannerBuildItem != null) {
possibleSupplier = bannerBuildItem.getBannerSupplier();
}
// Dev UI Log Stream
RuntimeValue<Optional<Handler>> devUiLogHandler = null;
if (logStreamHandlerBuildItem.isPresent()) {
devUiLogHandler = logStreamHandlerBuildItem.get().getHandlerValue();
}
boolean alwaysEnableLogStream = false;
if (!logStreamBuildItems.isEmpty()) {
alwaysEnableLogStream = true;
}
recorder.initializeLogging(log, buildLog, alwaysEnableLogStream, devUiLogHandler, handlers, namedHandlers, consoleFormatItems.stream().map(LogConsoleFormatBuildItem::getFormatterValue).collect(Collectors.toList()), possibleSupplier, launchModeBuildItem.getLaunchMode());
LogConfig logConfig = new LogConfig();
ConfigInstantiator.handleObject(logConfig);
for (LogCleanupFilterBuildItem i : logCleanupFilters) {
CleanupFilterConfig value = new CleanupFilterConfig();
LogCleanupFilterElement filterElement = i.getFilterElement();
value.ifStartsWith = filterElement.getMessageStarts();
value.targetLevel = filterElement.getTargetLevel() == null ? org.jboss.logmanager.Level.DEBUG : filterElement.getTargetLevel();
logConfig.filters.put(filterElement.getLoggerName(), value);
}
ConsoleRuntimeConfig crc = new ConsoleRuntimeConfig();
ConfigInstantiator.handleObject(crc);
LoggingSetupRecorder.initializeBuildTimeLogging(logConfig, buildLog, crc, launchModeBuildItem.getLaunchMode());
((QuarkusClassLoader) Thread.currentThread().getContextClassLoader()).addCloseTask(new Runnable() {
@Override
public void run() {
InitialConfigurator.DELAYED_HANDLER.buildTimeComplete();
}
});
}
return new LoggingSetupBuildItem();
}
Aggregations