From ff787e59e70a64d50af9244d641edbbde948b2f1 Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Thu, 21 Mar 2024 14:02:09 -0700 Subject: [PATCH] Always log registered `ServiceLoader` providers at INFO level Motivation: Users should always see what `ServiceLoader` providers were available in the classpath and loaded. We should log it at `INFO` level. Modifications: - If `ServiceLoader` providers are loaded, log them at `INFO` level; Result: Users can always see if their classpath has `ServiceLoader` providers. --- .../io/servicetalk/utils/internal/ServiceLoaderUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/servicetalk-utils-internal/src/main/java/io/servicetalk/utils/internal/ServiceLoaderUtils.java b/servicetalk-utils-internal/src/main/java/io/servicetalk/utils/internal/ServiceLoaderUtils.java index 2c25e8ae8a..b5d57ff463 100644 --- a/servicetalk-utils-internal/src/main/java/io/servicetalk/utils/internal/ServiceLoaderUtils.java +++ b/servicetalk-utils-internal/src/main/java/io/servicetalk/utils/internal/ServiceLoaderUtils.java @@ -47,7 +47,11 @@ public static List loadProviders(final Class clazz, final ClassLoader for (T provider : ServiceLoader.load(clazz, classLoader)) { list.add(provider); } - logger.debug("Registered {} {}(s): {}", list.size(), clazz.getSimpleName(), list); - return list.isEmpty() ? emptyList() : unmodifiableList(list); + if (list.isEmpty()) { + logger.debug("ServiceLoader {}(s) registered: []", clazz.getSimpleName()); + return emptyList(); + } + logger.info("ServiceLoader {}(s) registered: {}", clazz.getSimpleName(), list); + return unmodifiableList(list); } }