Skip to content
Snippets Groups Projects
Commit 6ad2875a authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Use --show-preamble value to display (of not) plugin load info

parent 01120756
No related branches found
No related tags found
1 merge request!200Change strategy for modules registration to the ModuleRepository
#include <utils/PluginsLoader.hpp> #include <utils/PluginsLoader.hpp>
#include <utils/ConsoleManager.hpp>
#include <dlfcn.h> #include <dlfcn.h>
#include <rang.hpp> #include <rang.hpp>
...@@ -32,9 +34,11 @@ PluginsLoader::_open(const std::string& plugin) ...@@ -32,9 +34,11 @@ PluginsLoader::_open(const std::string& plugin)
auto handle = dlopen(plugin.c_str(), RTLD_NOW); auto handle = dlopen(plugin.c_str(), RTLD_NOW);
if (handle != nullptr) { if (handle != nullptr) {
m_dl_handler_stack.push(handle); m_dl_handler_stack.push(handle);
if (ConsoleManager::showPreamble()) {
std::cout << " * \"" << rang::fgB::green << plugin << rang::fg::reset << "\"\n"; std::cout << " * \"" << rang::fgB::green << plugin << rang::fg::reset << "\"\n";
}
} else { } else {
std::cout << " " << rang::fgB::red << "cannot load " << rang::fg::reset << '\"' << rang::fgB::yellow << plugin std::cerr << " " << rang::fgB::red << "cannot load " << rang::fg::reset << '\"' << rang::fgB::yellow << plugin
<< rang::fg::reset << "\"\n"; << rang::fg::reset << "\"\n";
} }
} }
...@@ -58,7 +62,7 @@ PluginsLoader::PluginsLoader() ...@@ -58,7 +62,7 @@ PluginsLoader::PluginsLoader()
std::vector<std::string> path_vector = split(paths); std::vector<std::string> path_vector = split(paths);
for (auto&& path : path_vector) { for (auto&& path : path_vector) {
if (access(path.c_str(), R_OK) == -1) { if (access(path.c_str(), R_OK) == -1) {
std::cout << ' ' << rang::fgB::red << 'X' << rang::fg::reset << " cannot access plugin dir \"" std::cerr << ' ' << rang::fgB::red << 'X' << rang::fg::reset << " cannot access plugin dir \""
<< rang::fgB::yellow << path << rang::fg::reset << "\"\n"; << rang::fgB::yellow << path << rang::fg::reset << "\"\n";
} else { } else {
for (auto&& entry : for (auto&& entry :
...@@ -79,13 +83,17 @@ PluginsLoader::PluginsLoader() ...@@ -79,13 +83,17 @@ PluginsLoader::PluginsLoader()
plugin_vector.resize(std::distance(plugin_vector.begin(), std::unique(plugin_vector.begin(), plugin_vector.end()))); plugin_vector.resize(std::distance(plugin_vector.begin(), std::unique(plugin_vector.begin(), plugin_vector.end())));
if (plugin_vector.size() > 0) { if (plugin_vector.size() > 0) {
if (ConsoleManager::showPreamble()) {
std::cout << rang::style::bold << "Loading plugins" << rang::style::reset << '\n'; std::cout << rang::style::bold << "Loading plugins" << rang::style::reset << '\n';
}
for (auto&& plugin : plugin_vector) { for (auto&& plugin : plugin_vector) {
this->_open(plugin); this->_open(plugin);
} }
if (ConsoleManager::showPreamble()) {
std::cout << "-------------------------------------------------------\n"; std::cout << "-------------------------------------------------------\n";
} }
} }
}
PluginsLoader::~PluginsLoader() PluginsLoader::~PluginsLoader()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment