Skip to content

Commit

Permalink
Merge pull request #6198 from lramati/py_log
Browse files Browse the repository at this point in the history
Python version of rs2::log_to_callback and rs2::log
  • Loading branch information
maloel authored Apr 6, 2020
2 parents 025fccf + d830b8d commit 32968a0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions wrappers/python/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ PYBIND11_MODULE(NAME, m) {
/** rs.hpp **/
m.def("log_to_console", &rs2::log_to_console, "min_severity"_a);
m.def("log_to_file", &rs2::log_to_file, "min_severity"_a, "file_path"_a);

py::class_<rs2::log_message> log_message(m, "log_message");
log_message.def("line_number", &rs2::log_message::line_number)
.def("filename", &rs2::log_message::filename)
.def("raw", &rs2::log_message::raw)
.def("full", &rs2::log_message::full)
.def("__str__", &rs2::log_message::raw)
.def("__repr__", &rs2::log_message::full);

m.def("log_to_callback", [](rs2_log_severity min_severity, std::function<void(rs2_log_severity, rs2::log_message)> callback)
{
rs2::log_to_callback(min_severity, callback);
}, "min_severity"_a, "callback"_a);
m.def("log", &rs2::log, "severity"_a, "message"_a);

// rs2::log?
/** end rs.hpp **/
}

0 comments on commit 32968a0

Please sign in to comment.