Skip to content

Commit fbb7913

Browse files
Improve module/plugin loading logging message order. (#93952)
1 parent 336928a commit fbb7913

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

docs/changelog/93952.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 93952
2+
summary: Improve module/plugin loading logging message.
3+
area: Infra/Plugins
4+
type: enhancement
5+
issues: [93881]

server/src/main/java/org/elasticsearch/plugins/PluginsService.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@ public PluginsService(Settings settings, Path configPath, Path modulesDirectory,
132132

133133
// load modules
134134
List<PluginDescriptor> modulesList = new ArrayList<>();
135+
Set<String> moduleNameList = new HashSet<>();
135136
if (modulesDirectory != null) {
136137
try {
137138
Set<PluginBundle> modules = PluginsUtils.getModuleBundles(modulesDirectory);
138-
modules.stream().map(PluginBundle::pluginDescriptor).forEach(modulesList::add);
139+
modules.stream().map(PluginBundle::pluginDescriptor).forEach(m -> {
140+
modulesList.add(m);
141+
moduleNameList.add(m.getName());
142+
});
139143
seenBundles.addAll(modules);
140144
} catch (IOException ex) {
141145
throw new IllegalStateException("Unable to initialize modules", ex);
@@ -173,8 +177,13 @@ public PluginsService(Settings settings, Path configPath, Path modulesDirectory,
173177

174178
// we don't log jars in lib/ we really shouldn't log modules,
175179
// but for now: just be transparent so we can debug any potential issues
176-
logPluginInfo(info.getModuleInfos(), "module", logger);
177-
logPluginInfo(pluginsList, "plugin", logger);
180+
for (String name : loadedPlugins.keySet()) {
181+
if (moduleNameList.contains(name)) {
182+
logger.info("loaded module [{}]", name);
183+
} else {
184+
logger.info("loaded plugin [{}]", name);
185+
}
186+
}
178187
}
179188

180189
// package-private for testing
@@ -194,17 +203,6 @@ static void checkMandatoryPlugins(Set<String> existingPlugins, Set<String> manda
194203
}
195204
}
196205

197-
private static void logPluginInfo(final List<PluginDescriptor> pluginDescriptors, final String type, final Logger logger) {
198-
assert pluginDescriptors != null;
199-
if (pluginDescriptors.isEmpty()) {
200-
logger.info("no " + type + "s loaded");
201-
} else {
202-
for (final String name : pluginDescriptors.stream().map(PluginDescriptor::getName).sorted().toList()) {
203-
logger.info("loaded " + type + " [" + name + "]");
204-
}
205-
}
206-
}
207-
208206
private static List<PluginRuntimeInfo> getRuntimeInfos(
209207
PluginIntrospector inspector,
210208
List<PluginDescriptor> pluginDescriptors,

0 commit comments

Comments
 (0)