Skip to content

Commit a50b231

Browse files
authored
Feature/configure logger (#9)
* Add static functions to switch verbosity levels Just a simple UI for changing to fatal (which will literally print nothing) or low (which is the quite verbose default of xbot/opensot) * Set fatal to default So nothing have to be changed w.r.t. to configuring the logger. Set the verbosity to low with the added static functions to recreate "old" behavior on runtime
1 parent 9b3e799 commit a50b231

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

python/pyxbot2_interface.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <xbot2_interface/robotinterface2.h>
2+
#include <xbot2_interface/logger.h>
23
#include <xbot2_interface/common/utils.h>
34

45
#include <pybind11/pybind11.h>
@@ -408,8 +409,14 @@ PYBIND11_MODULE(pyxbot2_interface, m) {
408409
.def("getChildLink", &Joint::getChildLink)
409410
;
410411

412+
py::class_<Logger, std::shared_ptr<Logger>>(m, "Logger")
413+
.def_static("set_verbosity_level_to_fatal", [](){ Logger::SetVerbosityLevel(Logger::Severity::FATAL); })
414+
.def_static("set_verbosity_level_to_low", [](){ Logger::SetVerbosityLevel(Logger::Severity::LOW); })
415+
;
416+
411417
py::class_<ModelJoint, Joint, ModelJoint::Ptr>(m, "ModelJoint", py::multiple_inheritance());
412418

413419
py::class_<RobotJoint, Joint, RobotJoint::Ptr>(m, "RobotJoint", py::multiple_inheritance());
414420

415421
}
422+

src/logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void LoggerClass::DefaultOnPrint(char *msg, int n_chars, Logger::Severity s)
181181
LoggerClass::LoggerClass(std::string name)
182182
: _endl(*this)
183183
, _name(name)
184-
, _verbosity_level(Logger::Severity::LOW)
184+
, _verbosity_level(Logger::Severity::FATAL)
185185
, _severity(Logger::Severity::LOW)
186186
, _on_print(&LoggerClass::DefaultOnPrint)
187187
{

0 commit comments

Comments
 (0)