diff --git a/example/01-echo/libp2p_echo_client.cpp b/example/01-echo/libp2p_echo_client.cpp index 385eadd7..10cb3384 100644 --- a/example/01-echo/libp2p_echo_client.cpp +++ b/example/01-echo/libp2p_echo_client.cpp @@ -25,7 +25,7 @@ groups: - name: main sink: console level: info - children + children: - name: libp2p # ---------------- )"); diff --git a/example/01-echo/libp2p_echo_server.cpp b/example/01-echo/libp2p_echo_server.cpp index 6f4017ba..e3984ff6 100644 --- a/example/01-echo/libp2p_echo_server.cpp +++ b/example/01-echo/libp2p_echo_server.cpp @@ -11,10 +11,29 @@ #include #include #include +#include +#include #include #include #include +namespace { + const std::string logger_config(R"( +# ---------------- +sinks: + - name: console + type: console + color: true +groups: + - name: main + sink: console + level: info + children: + - name: libp2p +# ---------------- + )"); +} // namespace + bool isInsecure(int argc, char **argv) { if (2 == argc) { const std::string insecure{"-insecure"}; @@ -56,6 +75,24 @@ int main(int argc, char **argv) { using libp2p::crypto::PublicKey; using libp2p::common::operator""_unhex; + // prepare log system + auto logging_system = std::make_shared( + std::make_shared(logger_config)); + auto r = logging_system->configure(); + if (not r.message.empty()) { + (r.has_error ? std::cerr : std::cout) << r.message << std::endl; + } + if (r.has_error) { + exit(EXIT_FAILURE); + } + + libp2p::log::setLoggingSystem(logging_system); + if (std::getenv("TRACE_DEBUG") != nullptr) { + libp2p::log::setLevelOfGroup("*", soralog::Level::TRACE); + } else { + libp2p::log::setLevelOfGroup("*", soralog::Level::ERROR); + } + // resulting PeerId should be // 12D3KooWEgUjBV5FJAuBSoNMRYFRHjV7PjZwRQ7b43EKX9g7D6xV KeyPair keypair{PublicKey{{Key::Type::Ed25519, diff --git a/example/03-gossip/gossip_chat_example.cpp b/example/03-gossip/gossip_chat_example.cpp index f00306d7..765f46b0 100644 --- a/example/03-gossip/gossip_chat_example.cpp +++ b/example/03-gossip/gossip_chat_example.cpp @@ -43,7 +43,7 @@ groups: - name: main sink: console level: info - children + children: - name: libp2p # ---------------- )"); diff --git a/example/04-dnstxt/ares_resolver.cpp b/example/04-dnstxt/ares_resolver.cpp index 8f9eaca7..5f53cf28 100644 --- a/example/04-dnstxt/ares_resolver.cpp +++ b/example/04-dnstxt/ares_resolver.cpp @@ -23,7 +23,7 @@ groups: - name: main sink: console level: info - children + children: - name: libp2p # ---------------- )");