blob: 8ef09626631d1853daf9db120c19f5e277cea8c7 [file] [log] [blame]
Matthias Andreas Benkard80909242022-02-03 20:47:47 +01001// SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
Matthias Andreas Benkardb8fbc372021-05-11 06:50:45 +02005package eu.mulk.quarkus.googlecloud.jsonlogging.deployment;
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +02006
Matthias Andreas Benkard090b8852022-09-03 18:23:23 +02007import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingConfiguration;
Matthias Andreas Benkard20210242022-01-15 10:39:30 +01008import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingRecorder;
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +02009import io.quarkus.deployment.annotations.BuildStep;
10import io.quarkus.deployment.annotations.ExecutionTime;
11import io.quarkus.deployment.annotations.Record;
12import io.quarkus.deployment.builditem.FeatureBuildItem;
13import io.quarkus.deployment.builditem.LogConsoleFormatBuildItem;
14
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010015/**
16 * Registers {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} as the formatter for the
17 * embedded JBoss Log Manager.
18 */
19public class GoogleCloudLoggingProcessor {
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020020
21 private static final String FEATURE = "googlecloud-jsonlogging";
22
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010023 /**
24 * Returns the feature name of {@code "googlecloud-jsonlogging"}.
25 *
26 * @return the feature {@code "googlecloud-jsonlogging"}
27 */
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020028 @BuildStep
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010029 public FeatureBuildItem feature() {
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020030 return new FeatureBuildItem(FEATURE);
31 }
32
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010033 /**
34 * Constructs a {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} at runtime and returns
35 * it.
36 *
37 * @param recorder the recorder that implements the construction process at runtime.
38 * @return an instance of {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter}.
39 */
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020040 @BuildStep
41 @Record(ExecutionTime.RUNTIME_INIT)
Matthias Andreas Benkard090b8852022-09-03 18:23:23 +020042 public LogConsoleFormatBuildItem setUpFormatter(
43 GoogleCloudJsonLoggingRecorder recorder, GoogleCloudJsonLoggingConfiguration configuration) {
44 return new LogConsoleFormatBuildItem(recorder.initialize(configuration));
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020045 }
46}