Skip to content

Commit 7765d8c

Browse files
authored
Merge pull request #463 from NVIDIA/plugin_logging
feat(//core/plugins): Gating plugin logging based on global config
2 parents 803eaf5 + 1d5a088 commit 7765d8c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

core/plugins/register_plugins.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,37 @@ namespace impl {
1414
class TRTorchPluginRegistry {
1515
public:
1616
TRTorchPluginRegistry() {
17-
trtorch_logger.log(util::logging::LogLevel::kINFO, "Instatiated the TRTorch plugin registry class");
1817
// register libNvInferPlugins and TRTorch plugins
1918
// trtorch_logger logging level is set to kERROR and reset back to kDEBUG.
2019
// This is because initLibNvInferPlugins initializes only a subset of plugins and logs them.
2120
// Plugins outside this subset in TensorRT are not being logged in this. So temporarily we disable this to prevent
2221
// multiple logging of same plugins. To provide a clear list of all plugins, we iterate through getPluginRegistry()
2322
// where it prints the list of all the plugins registered in TensorRT with their namespaces.
24-
trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
25-
initLibNvInferPlugins(&trtorch_logger, "");
26-
trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kDEBUG);
23+
plugin_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
24+
initLibNvInferPlugins(&plugin_logger, "");
25+
plugin_logger.set_reportable_log_level(util::logging::get_logger().get_reportable_log_level());
2726

2827
int numCreators = 0;
2928
auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
3029
for (int k = 0; k < numCreators; ++k) {
3130
if (!pluginsList[k]) {
32-
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
31+
plugin_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
3332
continue;
3433
}
3534
std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
36-
trtorch_logger.log(
35+
plugin_logger.log(
3736
util::logging::LogLevel::kDEBUG,
3837
"Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) +
3938
", Namespace: " + pluginNamespace);
4039
}
41-
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
40+
plugin_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
4241
}
4342

4443
public:
45-
util::logging::TRTorchLogger trtorch_logger =
46-
util::logging::TRTorchLogger("[TRTorch Plugins Context] - ", util::logging::LogLevel::kDEBUG, true);
44+
util::logging::TRTorchLogger plugin_logger = util::logging::TRTorchLogger(
45+
"[TRTorch Plugins Context] - ",
46+
util::logging::get_logger().get_reportable_log_level(),
47+
util::logging::get_logger().get_is_colored_output_on());
4748
};
4849

4950
namespace {

0 commit comments

Comments
 (0)