Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use parameterized messages instead of string formatting for logging #699

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public void customize(AsyncAPI asyncAPI) {
}

try {
log.debug("Generate json-schema for %s".formatted(entry.getKey()));
log.debug("Generate json-schema for {}", entry.getKey());

Object jsonSchema = jsonSchemaGenerator.fromSchema(schema, schemas);
schema.getExtensionFields().putIfAbsent(EXTENSION_JSON_SCHEMA, jsonSchema);
} catch (Exception ex) {
log.warn("Unable to create json-schema for %s".formatted(entry.getKey()), ex);
log.warn("Unable to create json-schema for {}", entry.getKey(), ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ protected synchronized void initAsyncAPI() {
.build();

for (AsyncApiCustomizer customizer : customizers) {
log.debug(
"Starting customizer %s".formatted(customizer.getClass().getName()));
log.debug("Starting customizer {}", customizer.getClass().getName());
customizer.customize(asyncAPI);
}
this.asyncAPIResult = new AsyncAPIResult(asyncAPI, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ private void processAsyncApiPayloadAnnotation(Map<String, Schema> schemas, Strin
}

} else if (withPayloadAnnotatedFields.size() > 1) {
log.warn(("Found more than one field with @AsyncApiPayload annotation in class %s. "
+ "Falling back and ignoring annotation.")
.formatted(type.getName()));
log.warn(
("Found more than one field with @AsyncApiPayload annotation in class {}. "
+ "Falling back and ignoring annotation."),
type.getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private T getExampleValueFromSchemaAnnotation(Schema schema) {
// value (i.e. OffsetDateTime) is represented as string
return exampleValueGenerator.createStringExample(exampleValue.toString());
} catch (IllegalArgumentException ex) {
log.debug("Unable to convert example to JSON: %s".formatted(exampleValue.toString()), ex);
log.debug("Unable to convert example to JSON: {}", exampleValue, ex);
}

return exampleValueGenerator.createEmptyObjectExample();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private Class<?> extractClass(Type parameterType) {
// no generics used - just a normal type
return Class.forName(parameterType.getTypeName());
} catch (Exception ex) {
log.info("Unable to extract generic data type of %s".formatted(parameterType), ex);
log.info("Unable to extract generic data type of {}", parameterType, ex);
}
return Void.class;
}
Expand All @@ -122,7 +122,7 @@ private Class<?> extractActualGenericClass(ParameterizedType parameterType, Stri
try {
return Class.forName(typeName);
} catch (ClassNotFoundException ex) {
log.debug("Unable to find class for type %s".formatted(typeName), ex);
log.debug("Unable to find class for type {}", typeName, ex);
}

return Void.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public ResponseEntity<String> publish(@RequestParam String topic, @RequestBody M

@Override
public void afterPropertiesSet() {
log.debug(
"Message publishing via %s is active.".formatted(this.getClass().getSimpleName()));
log.debug("Message publishing via {} is active.", this.getClass().getSimpleName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ApiSystemTest {
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding())));
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));

private String baseUrl() {
String host = environment.getServiceHost(APP_NAME, APP_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ApiSystemTest {
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding())));
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));

private String baseUrl() {
String host = environment.getServiceHost(APP_NAME, APP_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ApiSystemTest {
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding())));
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));

private String baseUrl() {
String host = environment.getServiceHost(APP_NAME, APP_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ApiSystemTest {
public DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding())));
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));

private String baseUrl() {
String host = environment.getServiceHost(APP_NAME, APP_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ApiSystemTest {
public DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding())));
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));

private String baseUrl() {
String host = environment.getServiceHost(APP_NAME, APP_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void send(String channelName, Map<String, String> headers, Object payload
try {
message.setStringProperty(name, value);
} catch (JMSException ex) {
log.warn("Unable to set JMS Header key=%s value=%s".formatted(name, value), ex);
log.warn("Unable to set JMS Header key={} value={}", name, value, ex);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void send(String topic, String key, Map<String, String> headers, Object p
.toCompletableFuture()
.join();
} else {
log.warn("Kafka producer for topic %s is not configured".formatted(topic));
log.warn("Kafka producer for topic {} is not configured", topic);
}
}

Expand Down