hive fmt/spdlog updates

This commit is contained in:
Jason Rhinelander 2022-07-19 15:22:38 -03:00
parent f6019210c3
commit f9371233ee
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262
6 changed files with 17 additions and 21 deletions

View File

@ -26,7 +26,7 @@ namespace tooling
auto routerId = llarp::RouterID(context->router->pubkey());
container[routerId] = context;
std::cout << "Generated router with ID " << routerId << std::endl;
fmt::print("Generated router with ID {}\n", routerId);
}
void
@ -46,9 +46,9 @@ namespace tooling
{
auto& container = (isRelay ? relays : clients);
for (auto [routerId, ctx] : container)
for (const auto& [routerId, ctx] : container)
{
routerMainThreads.emplace_back([=]() {
routerMainThreads.emplace_back([ctx = ctx, isRelay = isRelay]() {
ctx->Run(llarp::RuntimeOptions{false, false, isRelay});
});
std::this_thread::sleep_for(2ms);

View File

@ -18,4 +18,3 @@ pybind11_add_module(pyllarp MODULE
)
target_link_libraries(pyllarp PUBLIC liblokinet)
target_include_directories(pyllarp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_log_tag(pyllarp)

View File

@ -17,11 +17,7 @@ namespace llarp
.def("ToPublic", &SecretKey::toPublic);
py::class_<Signature>(mod, "Signature")
.def(py::init<>())
.def("__repr__", [](const Signature sig) -> std::string {
std::stringstream ss;
ss << sig;
return ss.str();
});
.def("__repr__", [](const Signature& sig) { return sig.ToHex(); });
}
} // namespace llarp

View File

@ -1,12 +1,12 @@
#include <common.hpp>
#include <memory>
#include <llarp/util/logging/logger.hpp>
#include <llarp/util/logging.hpp>
namespace llarp
{
struct PyLogger
{
std::unique_ptr<LogSilencer> shutup;
std::optional<llarp::log::Level> silenced;
};
void
@ -16,15 +16,14 @@ namespace llarp
.def(py::init<>())
.def_property(
"shutup",
[](PyLogger& self) { return self.shutup != nullptr; },
[](PyLogger& self) { return self.silenced.has_value(); },
[](PyLogger& self, bool shutup) {
if (self.shutup == nullptr && shutup)
if (shutup and not self.silenced)
self.silenced = llarp::log::get_level_default();
else if (not shutup and self.silenced)
{
self.shutup = std::make_unique<LogSilencer>();
}
else if (self.shutup != nullptr && shutup == false)
{
self.shutup.reset();
llarp::log::reset_level(*self.silenced);
self.silenced.reset();
}
});
}

View File

@ -1,6 +1,8 @@
#include <llarp/router_contact.hpp>
#include <llarp/dht/key.hpp>
#include <common.hpp>
#include <llarp/util/time.hpp>
#include "common.hpp"
namespace llarp
{

View File

@ -1,5 +1,5 @@
#include "common.hpp"
#include <llarp/util/logging/logger.hpp>
#include <llarp/util/logging.hpp>
PYBIND11_MODULE(pyllarp, m)
{
@ -20,6 +20,6 @@ PYBIND11_MODULE(pyllarp, m)
llarp::path::PathHopConfig_Init(m);
llarp::handlers::PyHandler_Init(m);
llarp::service::Address_Init(m);
m.def("EnableDebug", []() { llarp::SetLogLevel(llarp::eLogDebug); });
m.def("EnableDebug", []() { llarp::log::reset_level(llarp::log::Level::debug); });
llarp::Logger_Init(m);
}