Search in sources :

Example 1 with CleanupFilterConfig

use of io.quarkus.runtime.logging.CleanupFilterConfig 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();
}
Also used : LogConsoleFormatBuildItem(io.quarkus.deployment.builditem.LogConsoleFormatBuildItem) Optional(java.util.Optional) Handler(java.util.logging.Handler) ConsoleRuntimeConfig(io.quarkus.runtime.console.ConsoleRuntimeConfig) QuarkusClassLoader(io.quarkus.bootstrap.classloading.QuarkusClassLoader) ConsoleFormatterBannerBuildItem(io.quarkus.deployment.builditem.ConsoleFormatterBannerBuildItem) RuntimeValue(io.quarkus.runtime.RuntimeValue) CleanupFilterConfig(io.quarkus.runtime.logging.CleanupFilterConfig) LogCleanupFilterElement(io.quarkus.runtime.logging.LogCleanupFilterElement) LogConfig(io.quarkus.runtime.logging.LogConfig) BuildStep(io.quarkus.deployment.annotations.BuildStep) LogRecord(java.util.logging.LogRecord) Record(io.quarkus.deployment.annotations.Record)

Aggregations

QuarkusClassLoader (io.quarkus.bootstrap.classloading.QuarkusClassLoader)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 Record (io.quarkus.deployment.annotations.Record)1 ConsoleFormatterBannerBuildItem (io.quarkus.deployment.builditem.ConsoleFormatterBannerBuildItem)1 LogConsoleFormatBuildItem (io.quarkus.deployment.builditem.LogConsoleFormatBuildItem)1 RuntimeValue (io.quarkus.runtime.RuntimeValue)1 ConsoleRuntimeConfig (io.quarkus.runtime.console.ConsoleRuntimeConfig)1 CleanupFilterConfig (io.quarkus.runtime.logging.CleanupFilterConfig)1 LogCleanupFilterElement (io.quarkus.runtime.logging.LogCleanupFilterElement)1 LogConfig (io.quarkus.runtime.logging.LogConfig)1 Optional (java.util.Optional)1 Handler (java.util.logging.Handler)1 LogRecord (java.util.logging.LogRecord)1