Skip to content

Commit

Permalink
libdnf5 plugins conf: Log warn if plugin name differs from value in cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel authored and Conan-Kudo committed Sep 8, 2023
1 parent 41a64a6 commit 88d747e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions libdnf5/plugin/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,21 @@ std::string Plugins::find_plugin_library(const std::string & plugin_name) {
throw PluginError(M_("Cannot find plugin library \"{}\""), library_name);
}

void Plugins::load_plugin_library(ConfigParser && parser, const std::string & file_path) {
void Plugins::load_plugin_library(
ConfigParser && parser, const std::string & file_path, const std::string & plugin_name) {
auto & logger = *base->get_logger();
logger.debug("Loading plugin library file=\"{}\"", file_path);
auto plugin = std::make_unique<PluginLibrary>(*base, std::move(parser), file_path);
auto * iplugin = plugin->get_iplugin();
plugins.emplace_back(std::move(plugin));
auto name = iplugin->get_name();
if (name != plugin_name) {
logger.warning(
"A mess in the plugin name. The name from the configuration file is \"{}\" and the real name is \"{}\".",
plugin_name,
name);
}
auto version = iplugin->get_version();
plugins.emplace_back(std::move(plugin));
logger.info(
"Loaded libdnf plugin \"{}\" (\"{}\"), version=\"{}.{}.{}\"",
name,
Expand Down Expand Up @@ -171,7 +178,7 @@ void Plugins::load_plugin(const std::string & config_file_path) {
}

auto library_path = find_plugin_library(plugin_name);
load_plugin_library(std::move(parser), library_path);
load_plugin_library(std::move(parser), library_path, plugin_name);
}

void Plugins::load_plugins(const std::string & config_dir_path) {
Expand Down
2 changes: 1 addition & 1 deletion libdnf5/plugin/plugins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Plugins {
std::string find_plugin_library(const std::string & plugin_name);

/// Loads the plugin from the library defined by the file path.
void load_plugin_library(ConfigParser && parser, const std::string & file_path);
void load_plugin_library(ConfigParser && parser, const std::string & file_path, const std::string & plugin_name);

Base * base;
std::vector<std::unique_ptr<Plugin>> plugins;
Expand Down

0 comments on commit 88d747e

Please sign in to comment.