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/ConsoleManager.hpp>
#include <dlfcn.h>
#include <rang.hpp>
......@@ -32,9 +34,11 @@ PluginsLoader::_open(const std::string& plugin)
auto handle = dlopen(plugin.c_str(), RTLD_NOW);
if (handle != nullptr) {
m_dl_handler_stack.push(handle);
if (ConsoleManager::showPreamble()) {
std::cout << " * \"" << rang::fgB::green << plugin << rang::fg::reset << "\"\n";
}
} 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";
}
}
......@@ -58,7 +62,7 @@ PluginsLoader::PluginsLoader()
std::vector<std::string> path_vector = split(paths);
for (auto&& path : path_vector) {
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";
} else {
for (auto&& entry :
......@@ -79,13 +83,17 @@ PluginsLoader::PluginsLoader()
plugin_vector.resize(std::distance(plugin_vector.begin(), std::unique(plugin_vector.begin(), plugin_vector.end())));
if (plugin_vector.size() > 0) {
if (ConsoleManager::showPreamble()) {
std::cout << rang::style::bold << "Loading plugins" << rang::style::reset << '\n';
}
for (auto&& plugin : plugin_vector) {
this->_open(plugin);
}
if (ConsoleManager::showPreamble()) {
std::cout << "-------------------------------------------------------\n";
}
}
}
PluginsLoader::~PluginsLoader()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment