Skip to content

Commit fbcdb59

Browse files
committed
Quarkus logging
1 parent 817724f commit fbcdb59

File tree

57 files changed

+444
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+444
-532
lines changed

horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/PersistentLog.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
88
import org.eclipse.microprofile.openapi.annotations.media.Schema;
9-
import org.jboss.logging.Logger;
109

1110
import com.fasterxml.jackson.annotation.JsonProperty;
1211

@@ -38,17 +37,4 @@ public PersistentLog(int level, String message) {
3837
this.timestamp = Instant.now();
3938
}
4039

41-
public static Logger.Level logLevel(int level) {
42-
switch (level) {
43-
case DEBUG:
44-
return Logger.Level.DEBUG;
45-
case INFO:
46-
return Logger.Level.INFO;
47-
case WARN:
48-
return Logger.Level.WARN;
49-
case ERROR:
50-
default:
51-
return Logger.Level.ERROR;
52-
}
53-
}
5440
}

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCommentAction.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,13 @@ public Uni<String> execute(JsonNode config, JsonNode secrets, Object payload) {
7070
return post(path, secrets, JsonNodeFactory.instance.objectNode().put("body", comment))
7171
.onItem().transformToUni(response -> {
7272
if (response.statusCode() < 400) {
73-
return Uni.createFrom()
74-
.item(String.format("Successfully(%d) added comment to %s", response.statusCode(), path));
73+
return Uni.createFrom().item("Successfully(" + response.statusCode() + ") added comment to " + path);
7574
} else if (response.statusCode() == 403 && response.getHeader("Retry-After") != null) {
7675
return retry(response, config, secrets, payload);
77-
7876
} else {
79-
return Uni.createFrom().failure(new RuntimeException(
80-
String.format("Failed to add comment to %s, response %d: %s",
81-
path, response.statusCode(), response.bodyAsString())));
77+
String message = "Failed to add comment to " + path + ", response" + response.statusCode() + ":\n"
78+
+ response.bodyAsString();
79+
return Uni.createFrom().failure(new RuntimeException(message));
8280
}
8381
}).onFailure().transform(t -> new RuntimeException("Failed to add comment to " + path + ": " + t.getMessage()));
8482
}

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCreateAction.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ public Uni<String> execute(JsonNode config, JsonNode secrets, Object payload) {
4747
.put("title", title).put("body", body).set("labels", JsonNodeFactory.instance.arrayNode().add("horreum")))
4848
.onItem().transformToUni(response -> {
4949
if (response.statusCode() < 400) {
50-
return Uni.createFrom()
51-
.item(String.format("Successfully(%d) created issue in %s", response.statusCode(), path));
50+
return Uni.createFrom().item("Successfully(" + response.statusCode() + ") created issue in " + path);
5251
} else if (response.statusCode() == 403 && response.getHeader("Retry-After") != null) {
5352
return retry(response, config, secrets, payload);
5453
} else {
55-
return Uni.createFrom().failure(new RuntimeException(
56-
String.format("Failed to create issue in %s, response %d: %s",
57-
path, response.statusCode(), response.bodyAsString())));
54+
String message = "Failed to create issue in " + path + ", response" + response.statusCode() + ":\n"
55+
+ response.bodyAsString();
56+
return Uni.createFrom().failure(new RuntimeException(message));
5857
}
5958
}).onFailure()
6059
.transform(t -> new RuntimeException("Failed to create issue in " + path + ": " + t.getMessage()));

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubPluginBase.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import jakarta.enterprise.inject.Instance;
66
import jakarta.inject.Inject;
77

8-
import org.jboss.logging.Logger;
9-
108
import com.fasterxml.jackson.databind.JsonNode;
119

10+
import io.quarkus.logging.Log;
1211
import io.smallrye.mutiny.Uni;
1312
import io.vertx.core.http.HttpMethod;
1413
import io.vertx.core.http.RequestOptions;
@@ -17,7 +16,6 @@
1716
import io.vertx.mutiny.ext.web.client.HttpResponse;
1817

1918
public abstract class GitHubPluginBase {
20-
protected static final Logger log = Logger.getLogger(GitHubPluginBase.class);
2119

2220
@Inject
2321
Vertx vertx;
@@ -62,7 +60,7 @@ protected Uni<HttpResponse<Buffer>> post(String path, JsonNode secrets, JsonNode
6260

6361
protected Uni<String> retry(HttpResponse<Buffer> response, JsonNode config, JsonNode secrets, Object payload) {
6462
int retryAfter = Integer.parseInt(response.getHeader("Retry-After"));
65-
log.warnf("Exceeded Github request limits, retrying after %d seconds", retryAfter);
63+
Log.warnf("Exceeded Github request limits, retrying after %d seconds", retryAfter);
6664
return Uni.createFrom()
6765
.emitter(em -> vertx.setTimer(TimeUnit.SECONDS.toMillis(retryAfter), id -> execute(config, secrets, payload)
6866
.subscribe().with(em::complete, em::fail)));

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/HttpAction.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import jakarta.inject.Inject;
99

1010
import org.eclipse.microprofile.config.inject.ConfigProperty;
11-
import org.jboss.logging.Logger;
1211

1312
import com.fasterxml.jackson.databind.JsonNode;
1413

1514
import io.hyperfoil.tools.horreum.entity.data.AllowedSiteDAO;
1615
import io.hyperfoil.tools.horreum.svc.ServiceException;
1716
import io.hyperfoil.tools.horreum.svc.Util;
17+
import io.quarkus.logging.Log;
1818
import io.smallrye.mutiny.Uni;
1919
import io.vertx.core.http.HttpMethod;
2020
import io.vertx.core.http.HttpVersion;
@@ -26,7 +26,6 @@
2626

2727
@ApplicationScoped
2828
public class HttpAction implements ActionPlugin {
29-
private static final Logger log = Logger.getLogger(HttpAction.class);
3029

3130
public static final String TYPE_HTTP = "http";
3231

@@ -89,13 +88,13 @@ public Uni<String> execute(JsonNode config, JsonNode secrets, Object payload) {
8988
.setPort(url.getPort() >= 0 ? url.getPort() : url.getDefaultPort())
9089
.setURI(url.getFile())
9190
.setSsl("https".equalsIgnoreCase(url.getProtocol()));
92-
log.infof("Sending event to %s", url);
91+
Log.infof("Sending event to %s", url);
9392
return http1xClient.request(HttpMethod.POST, options)
9493
.putHeader("Content-Type", "application/json")
9594
.sendBuffer(Buffer.buffer(body.toString()))
9695
.onItem().transform(response -> {
9796
if (response.statusCode() < 400) {
98-
return String.format("Successfully(%d) notified hook: %s", response.statusCode(), url);
97+
return "Successfully(" + response.statusCode() + ") notified hook: " + url;
9998
} else {
10099
throw new IllegalArgumentException("Failed to POST " + url + ", response " + response.statusCode()
101100
+ ": " + response.bodyAsString());

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/SlackChannelMessageAction.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66

77
import org.apache.http.HttpStatus;
88
import org.eclipse.microprofile.config.ConfigProvider;
9-
import org.jboss.logging.Logger;
109

1110
import com.fasterxml.jackson.databind.JsonNode;
1211
import com.fasterxml.jackson.databind.node.ArrayNode;
1312
import com.fasterxml.jackson.databind.node.ObjectNode;
1413

1514
import io.hyperfoil.tools.horreum.svc.Util;
15+
import io.quarkus.logging.Log;
1616
import io.smallrye.mutiny.Uni;
1717
import io.vertx.core.json.JsonObject;
1818

1919
@ApplicationScoped
2020
public class SlackChannelMessageAction extends SlackPluginBase implements ActionPlugin {
21-
private static final Logger log = Logger.getLogger(SlackChannelMessageAction.class);
2221
public static final String TYPE_SLACK_MESSAGE = "slack-channel-message";
2322

2423
@Override
@@ -28,7 +27,7 @@ public String type() {
2827

2928
@Override
3029
public void validate(JsonNode config, JsonNode secrets) {
31-
log.tracef("Validating config %s, secrets %s", config, secrets);
30+
Log.tracef("Validating config %s, secrets %s", config, secrets);
3231
requireProperties(secrets, "token");
3332
requireProperties(config, "formatter", "channel");
3433
}
@@ -64,29 +63,27 @@ public Uni<String> execute(JsonNode config, JsonNode secrets, Object payload) {
6463
text.put("text", comment);
6564
blocks.add(section);
6665

67-
log.debugf("Slack URL %s, token %s, body %s", url, token, body);
66+
Log.debugf("Slack URL %s, token %s, body %s", url, token, body);
6867
return post(url, secrets, body)
6968
.onItem().transformToUni(response -> {
7069
if (response.statusCode() < 400) {
7170
JsonObject status = response.bodyAsJsonObject();
7271
if (!status.getBoolean("ok")) {
73-
return Uni.createFrom().failure(
74-
new RuntimeException(
75-
String.format("Failed to post to channel %s, response %s", channel,
76-
status.getString("error"))));
72+
return Uni.createFrom().failure(new RuntimeException(
73+
"Failed to post to channel " + channel + ", response " + status.getString("error")));
7774
}
7875
return Uni.createFrom()
79-
.item(String.format("Successfully(%d) posted to channel %s", response.statusCode(), channel));
76+
.item("Successfully(" + response.statusCode() + ") posted to channel " + channel);
8077
} else if (response.statusCode() == HttpStatus.SC_TOO_MANY_REQUESTS
8178
&& response.getHeader("Retry-After") != null) {
82-
log.debugf("Slack POST needs retry: %s (%s)", response.toString(), response.bodyAsString());
79+
Log.debugf("Slack POST needs retry: %s (%s)", response.toString(), response.bodyAsString());
8380
return retry(response, config, secrets, payload);
84-
8581
} else {
86-
log.debugf("Slack POST failed: %s (%s)", response.statusCode(), response.bodyAsString());
87-
return Uni.createFrom().failure(new RuntimeException(
88-
String.format("Failed to post to channel %s, response %d: %s",
89-
channel, response.statusCode(), response.bodyAsString())));
82+
Log.debugf("Slack POST failed: %s (%s)", response.statusCode(), response.bodyAsString());
83+
84+
String message = "Failed to create issue in " + channel + ", response" + response.statusCode() + ":\n"
85+
+ response.bodyAsString();
86+
return Uni.createFrom().failure(new RuntimeException(message));
9087
}
9188
}).onFailure()
9289
.transform(t -> new RuntimeException("Failed to post message to " + channel + ": " + t.getMessage()));

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/SlackPluginBase.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
import jakarta.enterprise.inject.Instance;
88
import jakarta.inject.Inject;
99

10-
import org.jboss.logging.Logger;
11-
1210
import com.fasterxml.jackson.databind.JsonNode;
1311

12+
import io.quarkus.logging.Log;
1413
import io.smallrye.mutiny.Uni;
1514
import io.vertx.core.http.HttpMethod;
1615
import io.vertx.core.http.RequestOptions;
@@ -19,7 +18,6 @@
1918
import io.vertx.mutiny.ext.web.client.HttpResponse;
2019

2120
public abstract class SlackPluginBase {
22-
protected static final Logger log = Logger.getLogger(SlackPluginBase.class);
2321

2422
@Inject
2523
Vertx vertx;
@@ -48,7 +46,7 @@ protected Uni<HttpResponse<Buffer>> post(String path, JsonNode secrets, JsonNode
4846
if (token == null || token.isBlank()) {
4947
throw new IllegalArgumentException("Missing access token!");
5048
}
51-
log.debugf("POST %s (%s): %s", path, token, payload.toString());
49+
Log.debugf("POST %s (%s): %s", path, token, payload.toString());
5250
URL url;
5351
try {
5452
url = new URL(path);
@@ -72,7 +70,7 @@ protected Uni<HttpResponse<Buffer>> post(String path, JsonNode secrets, JsonNode
7270

7371
protected Uni<String> retry(HttpResponse<Buffer> response, JsonNode config, JsonNode secrets, Object payload) {
7472
int retryAfter = Integer.parseInt(response.getHeader("Retry-After"));
75-
log.warnf("Exceeded server request limits, retrying after %d seconds", retryAfter);
73+
Log.warnf("Exceeded server request limits, retrying after %d seconds", retryAfter);
7674
return Uni.createFrom()
7775
.emitter(em -> vertx.setTimer(TimeUnit.SECONDS.toMillis(retryAfter), id -> execute(config, secrets, payload)
7876
.subscribe().with(em::complete, em::fail)));

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/bus/BlockingTaskDispatcher.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
import jakarta.enterprise.context.ApplicationScoped;
1010
import jakarta.inject.Inject;
1111

12-
import org.jboss.logging.Logger;
13-
1412
import io.hyperfoil.tools.horreum.svc.Util;
13+
import io.quarkus.logging.Log;
1514
import io.quarkus.runtime.Startup;
1615
import io.vertx.core.Vertx;
1716

1817
@Startup
1918
@ApplicationScoped
2019
public class BlockingTaskDispatcher {
21-
private static final Logger log = Logger.getLogger(BlockingTaskDispatcher.class);
20+
2221
@Inject
2322
Vertx vertx;
2423

@@ -31,7 +30,7 @@ public void executeForTest(int testId, Runnable runnable) {
3130
TaskQueue queue = taskQueues.computeIfAbsent(testId, TaskQueue::new);
3231
queue.executeOrAdd(task);
3332
} catch (Exception e) {
34-
log.error("Failed to execute blocking task", e);
33+
Log.error("Failed to execute blocking task", e);
3534
} finally {
3635
promise.complete();
3736
}
@@ -41,7 +40,6 @@ public void executeForTest(int testId, Runnable runnable) {
4140
}
4241

4342
class TaskQueue {
44-
private static final Logger log = Logger.getLogger(TaskQueue.class);
4543
private final int testId;
4644
private final Queue<Runnable> queue = new ConcurrentLinkedQueue<>();
4745
private final ReentrantLock lock = new ReentrantLock();
@@ -54,21 +52,21 @@ public void executeOrAdd(Runnable runnable) {
5452
queue.add(runnable);
5553
do {
5654
if (lock.tryLock()) {
57-
log.debugf("This thread is going to execute tasks (%d) for test %d, lock level %d", queue.size(), testId,
55+
Log.debugf("This thread is going to execute tasks (%d) for test %d, lock level %d", queue.size(), testId,
5856
lock.getHoldCount());
5957
try {
6058
while (!queue.isEmpty()) {
6159
Runnable task = queue.poll();
6260
task.run();
6361
}
6462
} catch (Throwable t) {
65-
log.errorf(t, "Error executing task in the queue for test %d", testId);
63+
Log.errorf(t, "Error executing task in the queue for test %d", testId);
6664
} finally {
67-
log.debugf("Finished executing tasks for test %d", testId);
65+
Log.debugf("Finished executing tasks for test %d", testId);
6866
lock.unlock();
6967
}
7068
} else {
71-
log.debugf("There's another thread executing the tasks (%d) for test %d", queue.size(), testId);
69+
Log.debugf("There's another thread executing the tasks (%d) for test %d", queue.size(), testId);
7270
return;
7371
}
7472
} while (!queue.isEmpty());

horreum-backend/src/main/java/io/hyperfoil/tools/horreum/changedetection/FixedThresholdModel.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import jakarta.enterprise.context.ApplicationScoped;
77
import jakarta.inject.Inject;
88

9-
import org.jboss.logging.Logger;
10-
119
import com.fasterxml.jackson.core.JsonProcessingException;
1210
import com.fasterxml.jackson.databind.JsonNode;
1311
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -18,10 +16,10 @@
1816
import io.hyperfoil.tools.horreum.api.data.changeDetection.FixedThresholdDetectionConfig;
1917
import io.hyperfoil.tools.horreum.entity.alerting.ChangeDAO;
2018
import io.hyperfoil.tools.horreum.entity.alerting.DataPointDAO;
19+
import io.quarkus.logging.Log;
2120

2221
@ApplicationScoped
2322
public class FixedThresholdModel implements ChangeDetectionModel {
24-
private static final Logger log = Logger.getLogger(FixedThresholdModel.class);
2523

2624
@Inject
2725
ObjectMapper mapper;
@@ -36,7 +34,6 @@ public ConditionConfig config() {
3634
"Upper bound for acceptable datapoint values.");
3735
conditionConfig.defaults.put("model", new TextNode(ChangeDetectionModelType.names.FIXED_THRESHOLD));
3836
return conditionConfig;
39-
4037
}
4138

4239
@Override
@@ -55,29 +52,28 @@ public void analyze(List<DataPointDAO> dataPoints, JsonNode configuration, Consu
5552
if (config.min.enabled) {
5653
if ((!config.min.inclusive && dp.value <= config.min.value) || dp.value < config.min.value) {
5754
ChangeDAO c = ChangeDAO.fromDatapoint(dp);
58-
c.description = String.format("%f is below lower bound %f (%s)", dp.value, config.min.value,
55+
c.description = "%f is below lower bound %f (%s)".formatted(dp.value, config.min.value,
5956
config.min.inclusive ? "inclusive" : "exclusive");
60-
log.debug(c.description);
57+
Log.debug(c.description);
6158
changeConsumer.accept(c);
6259
return;
6360
}
6461
}
6562
if (config.max.enabled) {
6663
if ((!config.max.inclusive && dp.value >= config.max.value) || dp.value > config.max.value) {
6764
ChangeDAO c = ChangeDAO.fromDatapoint(dp);
68-
c.description = String.format("%f is above upper bound %f (%s)", dp.value, config.max.value,
65+
c.description = "%f is above upper bound %f (%s)".formatted(dp.value, config.max.value,
6966
config.max.inclusive ? "inclusive" : "exclusive");
70-
log.debug(c.description);
67+
Log.debug(c.description);
7168
changeConsumer.accept(c);
7269
}
7370
}
7471

7572
} catch (JsonProcessingException e) {
76-
String errMsg = String.format("Failed to parse configuration for variable %d", dp.variable.id);
77-
log.error(errMsg, e);
73+
String errMsg = "Failed to parse configuration for variable %d".formatted(dp.variable.id);
74+
Log.error(errMsg, e);
7875
throw new ChangeDetectionException(errMsg, e);
7976
}
80-
8177
}
8278

8379
@Override

0 commit comments

Comments
 (0)