lokinet/pybind/llarp/logger.cpp
dr7ana 46ad8d4058 Clang format include sorting + CMake
- includes are now sorted in consistent, logical order; first step in an attempt to fix the tomfoolery (no relation to Tom) brought in by include-what-you-use
- shuffled around some cmake linking to simplify dependency graph
- superfluous files removed
2023-10-24 12:11:51 -07:00

33 lines
780 B
C++

#include <llarp/util/logging.hpp>
#include <common.hpp>
#include <memory>
namespace llarp
{
struct PyLogger
{
std::optional<llarp::log::Level> silenced;
};
void
Logger_Init(py::module& mod)
{
py::class_<PyLogger>(mod, "LogContext")
.def(py::init<>())
.def_property(
"shutup",
[](PyLogger& self) { return self.silenced.has_value(); },
[](PyLogger& self, bool shutup) {
if (shutup and not self.silenced)
self.silenced = llarp::log::get_level_default();
else if (not shutup and self.silenced)
{
llarp::log::reset_level(*self.silenced);
self.silenced.reset();
}
});
}
} // namespace llarp