Skip to content

Commit

Permalink
refactor: SLF4J best practices (#3639)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne authored Dec 13, 2023
1 parent 5454c15 commit e2ffacd
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class KafkaExtension implements BeforeAllCallback, AfterAllCallback {
}

container.start();
LOGGER.info("Using bootstrapServer " + bootstrapServer());
LOGGER.info("Using bootstrapServer {}", bootstrapServer());
}

void prepareTopics(String topics, int partitions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RabbitMQExtension implements BeforeAllCallback, AfterAllCallback {
}

container.start();
LOGGER.info("Using hostPort " + host() + ":" + port());
LOGGER.info("Using hostPort {}:{}", host(), port());
}

@Override public void afterAll(ExtensionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public ZipkinActuatorImporter() {
String[] includes =
Binder.get(env).bind(PROPERTY_NAME_ACTUATOR_INCLUDE, String[].class).orElse(null);
if (includes == null || includes.length == 0) {
LOG.debug("no actuator configuration found under path " + PROPERTY_NAME_ACTUATOR_INCLUDE);
LOG.debug("no actuator configuration found under path {}", PROPERTY_NAME_ACTUATOR_INCLUDE);
return;
}

LOG.debug("attempting to load actuator configuration: " + Arrays.toString(includes));
LOG.debug("attempting to load actuator configuration: {}", Arrays.toString(includes));
try {
context.registerBean(Class.forName(actuatorImplClass));
} catch (Exception e) {
Expand All @@ -88,7 +88,7 @@ public ZipkinActuatorImporter() {
context.registerBean(Class.forName(include));
} catch (Exception e) {
// Skip any classes that didn't match due to drift
LOG.debug("skipping unloadable actuator config " + include, e);
LOG.debug("skipping unloadable actuator config {}", include, e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ public final class ZipkinModuleImporter implements ApplicationContextInitializer
Map<String, String> modules =
Binder.get(env).bind(PROPERTY_NAME_MODULE, Map.class).orElse(null);
if (modules == null || modules.isEmpty()) {
LOG.debug("no modules found under path " + PROPERTY_NAME_MODULE);
LOG.debug("no modules found under path {}", PROPERTY_NAME_MODULE);
return;
}

LOG.debug("attempting to load modules: " + modules.keySet());
LOG.debug("attempting to load modules: {}", modules.keySet());
for (Map.Entry<String, String> module : modules.entrySet()) {
try {
context.registerBean(Class.forName(module.getValue()));
} catch (Exception e) {
// Skip any classes that didn't match due to drift
LOG.debug("skipping unloadable module " + module.getKey(), e);
LOG.debug("skipping unloadable module {}", module.getKey(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static SelectTraceIdsFromSpan.Factory initialiseSelectTraceIdsFromSpan(CqlSessio
try {
return new SelectTraceIdsFromSpan.Factory(session);
} catch (DriverException ex) {
LOG.warn("failed to prepare annotation_query index statements: " + ex.getMessage());
LOG.warn("failed to prepare annotation_query index statements: {}", ex.getMessage(), ex);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static List<LocalDate> getDays(long endTs, @Nullable Long lookback) {
try {
return bytes == null ? null : InetAddress.getByAddress(bytes);
} catch (UnknownHostException e) {
LOG.debug("InetAddress.getByAddress failed with input {}: {}", string, e.getMessage());
LOG.debug("InetAddress.getByAddress failed with input {}: {}", string, e.getMessage(), e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* exception occurred.
*/
final class DefaultSessionFactory implements CassandraStorage.SessionFactory {
static final Logger LOG = LoggerFactory.getLogger(Schema.class);
static final Logger LOG = LoggerFactory.getLogger(DefaultSessionFactory.class);

/**
* Creates a session and ensures schema if configured. Closes the cluster and session if any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static CqlSession buildSession(
if (useSsl) config = config.withClass(SSL_ENGINE_FACTORY_CLASS, DefaultSslEngineFactory.class);

// Log categories can enable query logging
Logger requestLogger = LoggerFactory.getLogger(RequestLogger.class);
Logger requestLogger = LoggerFactory.getLogger(SessionBuilder.class);
if (requestLogger.isDebugEnabled()) {
config = config.withClass(REQUEST_TRACKER_CLASS, RequestLogger.class);
config = config.withBoolean(REQUEST_LOGGER_SUCCESS_ENABLED, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class CassandraStorageExtension implements BeforeAllCallback, AfterAllCal
}

container.start();
LOGGER.info("Using contactPoint " + contactPoint());
LOGGER.info("Using contactPoint {}", contactPoint());
globalSession = tryToInitializeSession(contactPoint());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ElasticsearchExtension implements BeforeAllCallback, AfterAllCallback {
}

container.start();
LOGGER.info("Using baseUrl " + baseUrl());
LOGGER.info("Using baseUrl {}", baseUrl());
}

@Override public void afterAll(ExtensionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MySQLExtension implements BeforeAllCallback, AfterAllCallback {
}

container.start();
LOGGER.info("Using hostPort " + host() + ":" + port());
LOGGER.info("Using hostPort {}:{}", host(), port());

try (MySQLStorage result = computeStorageBuilder().build()) {
CheckResult check = result.check();
Expand Down

0 comments on commit e2ffacd

Please sign in to comment.