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 | 090b885 | 2022-09-03 18:23:23 +0200 | [diff] [blame] | 7 | import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingConfiguration; |
Matthias Andreas Benkard | 2021024 | 2022-01-15 10:39:30 +0100 | [diff] [blame] | 8 | import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingRecorder; |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 9 | import io.quarkus.deployment.annotations.BuildStep; |
| 10 | import io.quarkus.deployment.annotations.ExecutionTime; |
| 11 | import io.quarkus.deployment.annotations.Record; |
| 12 | import io.quarkus.deployment.builditem.FeatureBuildItem; |
| 13 | import io.quarkus.deployment.builditem.LogConsoleFormatBuildItem; |
| 14 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 15 | /** |
| 16 | * Registers {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} as the formatter for the |
| 17 | * embedded JBoss Log Manager. |
| 18 | */ |
| 19 | public class GoogleCloudLoggingProcessor { |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 20 | |
| 21 | private static final String FEATURE = "googlecloud-jsonlogging"; |
| 22 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 23 | /** |
| 24 | * Returns the feature name of {@code "googlecloud-jsonlogging"}. |
| 25 | * |
| 26 | * @return the feature {@code "googlecloud-jsonlogging"} |
| 27 | */ |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 28 | @BuildStep |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 29 | public FeatureBuildItem feature() { |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 30 | return new FeatureBuildItem(FEATURE); |
| 31 | } |
| 32 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 33 | /** |
| 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 Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 40 | @BuildStep |
| 41 | @Record(ExecutionTime.RUNTIME_INIT) |
Matthias Andreas Benkard | 090b885 | 2022-09-03 18:23:23 +0200 | [diff] [blame] | 42 | public LogConsoleFormatBuildItem setUpFormatter( |
| 43 | GoogleCloudJsonLoggingRecorder recorder, GoogleCloudJsonLoggingConfiguration configuration) { |
| 44 | return new LogConsoleFormatBuildItem(recorder.initialize(configuration)); |
Matthias Andreas Benkard | c8144a9 | 2021-05-03 08:04:53 +0200 | [diff] [blame] | 45 | } |
| 46 | } |