Skip to content

Commit

Permalink
Added python function set_log_level_of_channel()
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Apr 12, 2023
1 parent b5334ef commit 9c1f4b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/hal_core/python_bindings/python_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@

namespace hal
{
/**
* Wrapper for LogManager::set_level_of_channel()
* @param channel_name - Name of log channel
* @param level - One of trace, debug, info, warn, err, critical, off
*/
void set_log_level_of_channel(std::string channel_name, std::string level);

namespace py = pybind11;

/**
Expand Down
14 changes: 14 additions & 0 deletions src/python_bindings/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

namespace hal
{
void set_log_level_of_channel(std::string channel_name, std::string level)
{
LogManager* lm = LogManager::get_instance();
log_info(channel_name, "Set log level of channel '{}' to '{}'.", channel_name, level);
if (lm) lm->set_level_of_channel(channel_name,level);
}

#ifdef PYBIND11_MODULE
PYBIND11_MODULE(hal_py, m)
{
Expand All @@ -15,6 +22,13 @@ namespace hal
m.def(
"log_info", [](std::string& message) { log_info("python_context", message); }, R"( some documentation info)");

m.def("set_log_level_of_channel", set_log_level_of_channel, py::arg("channel_name"), py::arg("level"), R"(
Set log level for channel.
:param str channel_name: Name of channel.
:param str level: Selected level, one out of [trace, debug, info, warn, err, critical, off].
)");

data_container_init(m);

core_utils_init(m);
Expand Down

0 comments on commit 9c1f4b4

Please sign in to comment.