Matthias Andreas Benkard | 8090924 | 2022-02-03 20:47:47 +0100 | [diff] [blame^] | 1 | // SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de> |
| 2 | // |
| 3 | // SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 | |
Matthias Andreas Benkard | b8fbc37 | 2021-05-11 06:50:45 +0200 | [diff] [blame] | 5 | package eu.mulk.quarkus.googlecloud.jsonlogging.deployment; |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 6 | |
Matthias Andreas Benkard | 2021024 | 2022-01-15 10:39:30 +0100 | [diff] [blame] | 7 | import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingRecorder; |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 8 | import io.quarkus.deployment.annotations.BuildStep; |
| 9 | import io.quarkus.deployment.annotations.ExecutionTime; |
| 10 | import io.quarkus.deployment.annotations.Record; |
| 11 | import io.quarkus.deployment.builditem.FeatureBuildItem; |
| 12 | import io.quarkus.deployment.builditem.LogConsoleFormatBuildItem; |
| 13 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 14 | /** |
| 15 | * Registers {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} as the formatter for the |
| 16 | * embedded JBoss Log Manager. |
| 17 | */ |
| 18 | public class GoogleCloudLoggingProcessor { |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 19 | |
| 20 | private static final String FEATURE = "googlecloud-jsonlogging"; |
| 21 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 22 | /** |
| 23 | * Returns the feature name of {@code "googlecloud-jsonlogging"}. |
| 24 | * |
| 25 | * @return the feature {@code "googlecloud-jsonlogging"} |
| 26 | */ |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 27 | @BuildStep |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 28 | public FeatureBuildItem feature() { |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 29 | return new FeatureBuildItem(FEATURE); |
| 30 | } |
| 31 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 32 | /** |
| 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 Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 39 | @BuildStep |
| 40 | @Record(ExecutionTime.RUNTIME_INIT) |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 41 | public LogConsoleFormatBuildItem setUpFormatter(GoogleCloudJsonLoggingRecorder recorder) { |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 42 | return new LogConsoleFormatBuildItem(recorder.initialize()); |
| 43 | } |
| 44 | } |