summaryrefslogtreecommitdiff
path: root/deployment/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/deployment/GoogleCloudLoggingProcessor.java
blob: fe012ee6281b32fd6235b8a681c987e87394662a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package eu.mulk.quarkus.googlecloud.jsonlogging.deployment;

import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingRecorder;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.LogConsoleFormatBuildItem;

/**
 * Registers {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} as the formatter for the
 * embedded JBoss Log Manager.
 */
public class GoogleCloudLoggingProcessor {

  private static final String FEATURE = "googlecloud-jsonlogging";

  /**
   * Returns the feature name of {@code "googlecloud-jsonlogging"}.
   *
   * @return the feature {@code "googlecloud-jsonlogging"}
   */
  @BuildStep
  public FeatureBuildItem feature() {
    return new FeatureBuildItem(FEATURE);
  }

  /**
   * Constructs a {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter} at runtime and returns
   * it.
   *
   * @param recorder the recorder that implements the construction process at runtime.
   * @return an instance of {@link eu.mulk.quarkus.googlecloud.jsonlogging.Formatter}.
   */
  @BuildStep
  @Record(ExecutionTime.RUNTIME_INIT)
  public LogConsoleFormatBuildItem setUpFormatter(GoogleCloudJsonLoggingRecorder recorder) {
    return new LogConsoleFormatBuildItem(recorder.initialize());
  }
}