Skip to content

feat(//core/plugins): Gating plugin logging based on global config #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions core/plugins/register_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,37 @@ namespace impl {
class TRTorchPluginRegistry {
public:
TRTorchPluginRegistry() {
trtorch_logger.log(util::logging::LogLevel::kINFO, "Instatiated the TRTorch plugin registry class");
// register libNvInferPlugins and TRTorch plugins
// trtorch_logger logging level is set to kERROR and reset back to kDEBUG.
// This is because initLibNvInferPlugins initializes only a subset of plugins and logs them.
// Plugins outside this subset in TensorRT are not being logged in this. So temporarily we disable this to prevent
// multiple logging of same plugins. To provide a clear list of all plugins, we iterate through getPluginRegistry()
// where it prints the list of all the plugins registered in TensorRT with their namespaces.
trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
initLibNvInferPlugins(&trtorch_logger, "");
trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kDEBUG);
plugin_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
initLibNvInferPlugins(&plugin_logger, "");
plugin_logger.set_reportable_log_level(util::logging::get_logger().get_reportable_log_level());

int numCreators = 0;
auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
for (int k = 0; k < numCreators; ++k) {
if (!pluginsList[k]) {
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
plugin_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
continue;
}
std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
trtorch_logger.log(
plugin_logger.log(
util::logging::LogLevel::kDEBUG,
"Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) +
", Namespace: " + pluginNamespace);
}
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
plugin_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
}

public:
util::logging::TRTorchLogger trtorch_logger =
util::logging::TRTorchLogger("[TRTorch Plugins Context] - ", util::logging::LogLevel::kDEBUG, true);
util::logging::TRTorchLogger plugin_logger = util::logging::TRTorchLogger(
"[TRTorch Plugins Context] - ",
util::logging::get_logger().get_reportable_log_level(),
util::logging::get_logger().get_is_colored_output_on());
};

namespace {
Expand Down