Skip to content

Commit 4247170

Browse files
authored
Use RuntimeValue to pass runtime config to recorder (#377)
* Use RuntimeValue to pass runtime config to recorder * Use RuntimeValue to pass runtime config to recorder
1 parent f923330 commit 4247170

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

deployment/src/main/java/io/quarkiverse/loggingmanager/deployment/LoggingManagerProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void includeRestEndpoints(BuildProducer<RouteBuildItem> routeProducer,
5858
routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
5959
.management()
6060
.routeFunction(loggingManagerConfig.basePath(),
61-
recorder.routeConsumer(bodyHandlerBuildItem.getHandler(), runtimeConfig))
61+
recorder.routeConsumer(bodyHandlerBuildItem.getHandler()))
6262
.displayOnNotFoundPage("LogManager All available loggers")
6363
.handler(loggerHandler)
6464
.build());
@@ -97,4 +97,4 @@ private static boolean shouldIncludeInOpenAPI(LaunchModeBuildItem launchMode, Lo
9797
return shouldInclude(launchMode, loggingManagerConfig);
9898
}
9999

100-
}
100+
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<maven.compiler.release>17</maven.compiler.release>
3232
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3333
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
34-
<quarkus.version>3.20.0</quarkus.version>
34+
<quarkus.version>3.20.2</quarkus.version>
3535
</properties>
3636
<dependencyManagement>
3737
<dependencies>
@@ -80,4 +80,4 @@
8080
</modules>
8181
</profile>
8282
</profiles>
83-
</project>
83+
</project>

runtime/src/main/java/io/quarkiverse/loggingmanager/LoggerManagerRecorder.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.util.function.Consumer;
44

5+
import jakarta.inject.Inject;
6+
7+
import io.quarkus.runtime.RuntimeValue;
58
import io.quarkus.runtime.annotations.Recorder;
69
import io.vertx.core.Handler;
710
import io.vertx.ext.web.Route;
@@ -10,6 +13,13 @@
1013
@Recorder
1114
public class LoggerManagerRecorder {
1215

16+
private final RuntimeValue<LoggingManagerRuntimeConfig> runtimeConfig;
17+
18+
@Inject
19+
public LoggerManagerRecorder(RuntimeValue<LoggingManagerRuntimeConfig> runtimeConfig) {
20+
this.runtimeConfig = runtimeConfig;
21+
}
22+
1323
public Handler<RoutingContext> loggerHandler() {
1424
return new LoggerHandler();
1525
}
@@ -18,12 +28,12 @@ public Handler<RoutingContext> levelHandler() {
1828
return new LevelHandler();
1929
}
2030

21-
public Consumer<Route> routeConsumer(Handler<RoutingContext> bodyHandler, LoggingManagerRuntimeConfig runtimeConfig) {
22-
if (runtimeConfig.enable()) {
31+
public Consumer<Route> routeConsumer(Handler<RoutingContext> bodyHandler) {
32+
if (runtimeConfig.getValue().enable()) {
2333
return route -> route.handler(bodyHandler);
2434
} else {
2535
return route -> route.handler(new LoggingManagerNotFoundHandler());
2636
}
2737

2838
}
29-
}
39+
}

0 commit comments

Comments
 (0)