Skip to content

Commit

Permalink
add plugins summary (hyperledger#5964)
Browse files Browse the repository at this point in the history
Signed-off-by: Sally MacFarlane <[email protected]>
  • Loading branch information
macfarla authored and Gabriel-Trintinalia committed Oct 20, 2023
1 parent 7c6418e commit 872c36e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public ConfigurationOverviewBuilder setEngineJwtFile(final String engineJwtFileP
/**
* Sets the environment variables.
*
* @param environment the enveironment variables
* @param environment the environment variables
* @return the builder
*/
public ConfigurationOverviewBuilder setEnvironment(final Map<String, String> environment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.services.BesuService;
import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
import org.hyperledger.besu.util.log.FramedLogMessage;

import java.io.IOException;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -104,6 +105,9 @@ public <T extends BesuService> Optional<T> getService(final Class<T> serviceType
* @param pluginsDir the plugins dir
*/
public void registerPlugins(final Path pluginsDir) {
final List<String> lines = new ArrayList<>();
lines.add("plugins dir " + pluginsDir.toAbsolutePath());
lines.add("");
checkState(
state == Lifecycle.UNINITIALIZED,
"Besu plugins have already been registered. Cannot register additional plugins.");
Expand All @@ -120,19 +124,24 @@ public void registerPlugins(final Path pluginsDir) {
try {
plugin.register(this);
LOG.info("Registered plugin of type {}.", plugin.getClass().getName());
lines.add(String.format("SUCCESS %s", plugin.getClass().getSimpleName()));
addPluginVersion(plugin);
} catch (final Exception e) {
LOG.error(
"Error registering plugin of type "
+ plugin.getClass().getName()
+ ", start and stop will not be called.",
e);
lines.add(String.format("ERROR %s", plugin.getClass().getSimpleName()));
continue;
}
plugins.add(plugin);
}

LOG.debug("Plugin registration complete.");
lines.add("");
lines.add("TOTAL = " + plugins.size());
LOG.debug(FramedLogMessage.generate(lines));

state = Lifecycle.REGISTERED;
}
Expand Down Expand Up @@ -259,7 +268,7 @@ List<BesuPlugin> getPlugins() {

private Optional<ClassLoader> pluginDirectoryLoader(final Path pluginsDir) {
if (pluginsDir != null && pluginsDir.toFile().isDirectory()) {
LOG.debug("Searching for plugins in {}", pluginsDir.toAbsolutePath().toString());
LOG.debug("Searching for plugins in {}", pluginsDir.toAbsolutePath());

try (final Stream<Path> pluginFilesList = Files.list(pluginsDir)) {
final URL[] pluginJarURLs =
Expand Down

0 comments on commit 872c36e

Please sign in to comment.