blob: 7d4a93f5a049ba9df6c2e584a55c679ca61f0f6d [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 Benkard20210242022-01-15 10:39:30 +01007import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingRecorder;
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +02008import io.quarkus.deployment.annotations.BuildStep;
9import io.quarkus.deployment.annotations.ExecutionTime;
10import io.quarkus.deployment.annotations.Record;
11import io.quarkus.deployment.builditem.FeatureBuildItem;
12import io.quarkus.deployment.builditem.LogConsoleFormatBuildItem;
13
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010014/**
15 * Registers {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} as the formatter for the
16 * embedded JBoss Log Manager.
17 */
18public class GoogleCloudLoggingProcessor {
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020019
20 private static final String FEATURE = "googlecloud-jsonlogging";
21
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010022 /**
23 * Returns the feature name of {@code "googlecloud-jsonlogging"}.
24 *
25 * @return the feature {@code "googlecloud-jsonlogging"}
26 */
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020027 @BuildStep
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010028 public FeatureBuildItem feature() {
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020029 return new FeatureBuildItem(FEATURE);
30 }
31
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010032 /**
33 * Constructs a {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} at runtime and returns
34 * it.
35 *
36 * @param recorder the recorder that implements the construction process at runtime.
37 * @return an instance of {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter}.
38 */
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020039 @BuildStep
40 @Record(ExecutionTime.RUNTIME_INIT)
Matthias Andreas Benkard348f2052022-01-15 16:13:01 +010041 public LogConsoleFormatBuildItem setUpFormatter(GoogleCloudJsonLoggingRecorder recorder) {
Matthias Andreas Benkardc8144a92021-05-03 08:04:53 +020042 return new LogConsoleFormatBuildItem(recorder.initialize());
43 }
44}