mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
31 lines
778 B
C++
31 lines
778 B
C++
#include <common.hpp>
|
|
#include <memory>
|
|
#include <llarp/util/logging.hpp>
|
|
|
|
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
|