diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e7871..71abedc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.14) project(Libp2pModulePlugin LANGUAGES CXX) +find_package(nlohmann_json REQUIRED) + if(DEFINED ENV{LOGOS_MODULE_BUILDER_ROOT}) include($ENV{LOGOS_MODULE_BUILDER_ROOT}/cmake/LogosModule.cmake) else() @@ -31,4 +33,6 @@ logos_module( tinycbor ) +target_link_libraries(libp2p_module_module_plugin PUBLIC nlohmann_json::nlohmann_json) + add_subdirectory(tutorial) diff --git a/flake.lock b/flake.lock index e5c2506..7c6d18b 100644 --- a/flake.lock +++ b/flake.lock @@ -148,16 +148,16 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1785247914, - "narHash": "sha256-W15T9ugMOkwjlySOpDxqK8UzCz4eCFMCcVRLGfbsQT0=", + "lastModified": 1785445744, + "narHash": "sha256-aLK2iPNsffW9Q2k2LlHq4BE6D25A6vmN9wPC+oz+M9o=", "owner": "vacp2p", "repo": "nim-libp2p", - "rev": "4116b2ff373232c95eb173834f7a8a881bb4828a", + "rev": "f169c5ed39f653a0718d00686a9fabc67194dabf", "type": "github" }, "original": { "owner": "vacp2p", - "ref": "fix/cbind/nim-ffi-bump", + "ref": "master", "repo": "nim-libp2p", "type": "github" } diff --git a/flake.nix b/flake.nix index e373867..01abfac 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { logos-module-builder.url = "github:logos-co/logos-module-builder"; - libp2p.url = "github:vacp2p/nim-libp2p/fix/cbind/nim-ffi-bump"; + libp2p.url = "github:vacp2p/nim-libp2p/master"; openmetrics-module = { url = "github:logos-co/openmetrics-module"; @@ -17,9 +17,28 @@ outputs = inputs@{ logos-module-builder, ... }: let + nixpkgs = logos-module-builder.inputs.nixpkgs; + systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]; + + forEachSystem = f: builtins.listToAttrs (map (system: { + name = system; + value = f system; + }) systems); + + libp2pInputs = { + packages = forEachSystem (system: { + cbind = inputs.libp2p.packages.${system}.cbind.overrideAttrs (old: { + buildPhase = builtins.replaceStrings + [ "--threads:on --opt:size --noMain --mm:refc --d:metrics" ] + [ "--threads:on --opt:size --noMain --mm:refc --d:metrics -d:chronicles_runtime_filtering=on" ] + old.buildPhase; + }); + }); + }; + externalLibInputs = { libp2p = { - input = inputs.libp2p; + input = libp2pInputs; packages.default = "cbind"; }; }; @@ -34,14 +53,6 @@ }; }; - nixpkgs = logos-module-builder.inputs.nixpkgs; - systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]; - - forEachSystem = f: builtins.listToAttrs (map (system: { - name = system; - value = f system; - }) systems); - # Pre-resolved store paths for the two .lgx bundles the e2e installs. e2eEnv = system: { LIBP2P_LGX_DIR = "${module.packages.${system}.lgx}"; diff --git a/src/plugin.cpp b/src/plugin.cpp index c591355..ba76fe0 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -55,6 +55,8 @@ void reapLateContext(std::future f) { } constexpr char kModuleVersion[] = "1.0.0"; + +std::atomic g_requestedLogLevel{LOG_LEVEL_DEBUG}; } void Libp2pModuleImpl::publishEmitEvent() { @@ -176,6 +178,7 @@ StdLogosResult Libp2pModuleImpl::createContext() { // identity; a supplied key gives a stable peer id across restarts. m_libp2pConfig.privKey = NimFfiBytes{m_privKey.empty() ? nullptr : m_privKey.data(), m_privKey.size()}; + m_libp2pConfig.logLevel = g_requestedLogLevel.load(); auto r = spawnContext(m_libp2pConfig); if (!r.ok) { @@ -213,6 +216,10 @@ StdLogosResult Libp2pModuleImpl::createNode(const std::string& config) { return createContext(); } +void Libp2pModuleImpl::setLogLevel(LogLevel level) { + g_requestedLogLevel.store(static_cast(level)); +} + void Libp2pModuleImpl::destroyContext() { if (!ctx) { return; diff --git a/src/plugin.h b/src/plugin.h index 901a56e..7ba11e8 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -54,6 +54,21 @@ struct SyncResult { LibP2PCtx* newCtx = nullptr; }; +// libp2p logs treat levels as inclusive minimum thresholds: +// `Trace` emits trace and above, `Debug` emits debug and above, etc. +// `None` is the lowest threshold, so it emits all logs; use `Fatal` for the +// quietest built-in threshold. +enum class LogLevel : int64_t { + None = LOG_LEVEL_NONE, // All logs. + Trace = LOG_LEVEL_TRACE, // Trace and above. + Debug = LOG_LEVEL_DEBUG, // Debug and above. + Info = LOG_LEVEL_INFO, // Info and above. + Notice = LOG_LEVEL_NOTICE, // Notice and above. + Warn = LOG_LEVEL_WARN, // Warn and above. + Error = LOG_LEVEL_ERROR, // Error and above. + Fatal = LOG_LEVEL_FATAL, // Fatal only. +}; + enum class KeyScheme : int64_t { Rsa = KEY_SCHEME_RSA, Ed25519 = KEY_SCHEME_ED25519, @@ -141,6 +156,8 @@ class Libp2pModuleImpl { std::function emitEvent; + static void setLogLevel(LogLevel level); + bool ok(); StdLogosResult status(); @@ -307,8 +324,8 @@ class Libp2pModuleImpl { // Same dance without the context check, for the `{.ffiStatic.}` bindings: // they take no ctx and run on the library's own static context. template - StdLogosResult callStaticWith(const char* errPrefix, Invoke&& invoke, Transform&& transform, - int awaitMs = kDefaultOpTimeoutMs) { + static StdLogosResult callStaticWith(const char* errPrefix, Invoke&& invoke, Transform&& transform, + int awaitMs = kDefaultOpTimeoutMs) { auto* p = new SyncPromise(); auto f = p->get_future(); int ret = invoke(p); @@ -328,3 +345,7 @@ class Libp2pModuleImpl { return transform(r); } }; + +inline void setLogLevel(LogLevel level) { + return Libp2pModuleImpl::setLogLevel(level); +} diff --git a/tutorial/docs/tutorial_0_introduction.md b/tutorial/docs/tutorial_0_introduction.md index 8ac9cd2..dce190c 100644 --- a/tutorial/docs/tutorial_0_introduction.md +++ b/tutorial/docs/tutorial_0_introduction.md @@ -40,8 +40,30 @@ These programs are examples, not long-running services. When a required operation fails, they print a useful error message to `stderr` and return `1`. Successful tutorials print progress to `stdout` and return `0`. -The `stdout` stream can be noisy because logs from the wrapped C binding -are also included. This is tracked in [issue #79](https://github.com/logos-co/logos-libp2p-module/issues/79). +## Controlling libp2p Logs + +The wrapped libp2p binding can emit runtime logs. Tutorials set the log +level to `LogLevel::Fatal` by default so `stdout` only shows the tutorial's +own progress messages during normal runs. Choose another level such as +`LogLevel::Info`, `LogLevel::Debug`, or `LogLevel::Trace` when you need more +detail while debugging: + +```cpp +setLogLevel(LogLevel::Debug); +// ... or +Libp2pModuleImpl::setLogLevel(LogLevel::Debug); +``` + +Log levels are inclusive minimum thresholds: `LogLevel::Trace` emits trace +and above, `LogLevel::Debug` emits debug and above, and so on. +`LogLevel::None` is the lowest threshold, so it emits all logs; it does not +disable logging. Use `LogLevel::Fatal` for the quietest built-in threshold. + +In your own application, `LogLevel::Error` is often a useful default. +It keeps normal output quiet while still surfacing conditions +that may indicate libp2p is misbehaving or that your integration code needs an +adjustment. Some error logs describe remote-peer behavior, retries, or +recoverable internal state, so they may not require any action from your side. ## Convert JSON Values Explicitly @@ -80,6 +102,9 @@ int main() { printf("=== Tutorial 0: Introduction and Common Patterns ===\n\n"); + // Silence logs from wrapped library. + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create and start a node @@ -181,6 +206,20 @@ tutorials with this command and then run it again: ```bash nix --extra-experimental-features 'nix-command flakes' develop --command ./tutorial/build_tutorials.sh ``` + +## Exercise: Enable libp2p debug logs + +Change this tutorial's log level from `LogLevel::None` to +`LogLevel::Debug`: + +```cpp +setLogLevel(LogLevel::Debug); +``` + +Compile the tutorial binaries again, using the same command from above. + +Run tutorial 0 again. You should now see libp2p debug logs in `stdout` +alongside the tutorial's own progress messages. ---

Creating and Starting a libp2p Node →

diff --git a/tutorial/docs/tutorial_10_peerstore.md b/tutorial/docs/tutorial_10_peerstore.md index bf8a838..51af45c 100644 --- a/tutorial/docs/tutorial_10_peerstore.md +++ b/tutorial/docs/tutorial_10_peerstore.md @@ -27,6 +27,8 @@ int main() { printf("=== Tutorial 10: Peer Store Management ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create two nodes diff --git a/tutorial/docs/tutorial_11_circuit_relay.md b/tutorial/docs/tutorial_11_circuit_relay.md index d837656..6ba9bdc 100644 --- a/tutorial/docs/tutorial_11_circuit_relay.md +++ b/tutorial/docs/tutorial_11_circuit_relay.md @@ -45,6 +45,8 @@ int main() { printf("=== Tutorial 11: Circuit Relay ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create three nodes diff --git a/tutorial/docs/tutorial_1_node_lifecycle.md b/tutorial/docs/tutorial_1_node_lifecycle.md index 236a042..491649a 100644 --- a/tutorial/docs/tutorial_1_node_lifecycle.md +++ b/tutorial/docs/tutorial_1_node_lifecycle.md @@ -23,13 +23,18 @@ Every program starts by including the module's single public header - `"plugin.h #include #include "plugin.h" +int main() +{ + printf("=== Tutorial 1: Creating and Starting a libp2p Node ===\n\n"); + + setLogLevel(LogLevel::Fatal); + ``` The main class we work with is `Libp2pModuleImpl`. Let's create one with default options: + ```cpp -int main() -{ // Create a libp2p node with default configuration. // By default it listens on 127.0.0.1 with a random port (tcp/0). Libp2pModuleImpl node; @@ -111,6 +116,8 @@ Always clean up by stopping the node when you're done. node.stop(); printf("Node stopped\n"); + printf("\n=== Tutorial 1 Complete ===\n"); + return 0; } diff --git a/tutorial/docs/tutorial_2_custom_config.md b/tutorial/docs/tutorial_2_custom_config.md index 7ee8dba..0dd029a 100644 --- a/tutorial/docs/tutorial_2_custom_config.md +++ b/tutorial/docs/tutorial_2_custom_config.md @@ -35,6 +35,10 @@ provide a custom address in the `addrs` field. int main() { + printf("=== Tutorial 2: Custom Node Configuration ===\n\n"); + + setLogLevel(LogLevel::Fatal); + ``` ## Method 1: Configure via C++ struct @@ -156,6 +160,20 @@ supplied via `Libp2pModuleOptions::fromJson()`. ``` +## Summary + +In this tutorial you learned: + - How to configure a node with a fixed port + - How to control connection limits + - How to pass options via C++ struct or JSON + - How to verify the node's actual bound addresses + +## Run tutorial + +```bash +./build/tutorial/tutorial_2_custom_config +``` + ## Exercise: Try different configurations Experiment with these variations: @@ -171,20 +189,6 @@ options.addrs = { "/ip4/0.0.0.0/tcp/9094" }; ``` - -## Summary - -In this tutorial you learned: - - How to configure a node with a fixed port - - How to control connection limits - - How to pass options via C++ struct or JSON - - How to verify the node's actual bound addresses - -## Run tutorial - -```bash -./build/tutorial/tutorial_2_custom_config -``` ---

← Creating and Starting a libp2p Node  |  Connecting Peers and Exchanging Data →

diff --git a/tutorial/docs/tutorial_3_connecting_peers.md b/tutorial/docs/tutorial_3_connecting_peers.md index 6f183a9..5e9b998 100644 --- a/tutorial/docs/tutorial_3_connecting_peers.md +++ b/tutorial/docs/tutorial_3_connecting_peers.md @@ -44,6 +44,8 @@ int main() { printf("=== Tutorial 3: Connecting Peers ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create and start two nodes diff --git a/tutorial/docs/tutorial_4_custom_protocol.md b/tutorial/docs/tutorial_4_custom_protocol.md index 6fed133..43e45db 100644 --- a/tutorial/docs/tutorial_4_custom_protocol.md +++ b/tutorial/docs/tutorial_4_custom_protocol.md @@ -58,6 +58,8 @@ int main() { printf("=== Tutorial 4: Custom Protocol Handlers ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create and start two nodes diff --git a/tutorial/docs/tutorial_5_kademlia_basics.md b/tutorial/docs/tutorial_5_kademlia_basics.md index a1d5aa0..cbfcd26 100644 --- a/tutorial/docs/tutorial_5_kademlia_basics.md +++ b/tutorial/docs/tutorial_5_kademlia_basics.md @@ -40,6 +40,8 @@ int main() { printf("=== Tutorial 5: Kademlia DHT Basics ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create two nodes diff --git a/tutorial/docs/tutorial_6_kademlia_providers.md b/tutorial/docs/tutorial_6_kademlia_providers.md index 1ded98e..cd39bb7 100644 --- a/tutorial/docs/tutorial_6_kademlia_providers.md +++ b/tutorial/docs/tutorial_6_kademlia_providers.md @@ -35,6 +35,8 @@ with the provider API. int main() { printf("=== Tutorial 6: Kademlia Provider Records ===\n\n"); + + setLogLevel(LogLevel::Fatal); ``` diff --git a/tutorial/docs/tutorial_7_gossipsub_polling.md b/tutorial/docs/tutorial_7_gossipsub_polling.md index 6b329dd..69cc7e9 100644 --- a/tutorial/docs/tutorial_7_gossipsub_polling.md +++ b/tutorial/docs/tutorial_7_gossipsub_polling.md @@ -37,6 +37,8 @@ int main() { printf("=== Tutorial 7: GossipSub - Polling for Messages ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create two nodes with GossipSub enabled diff --git a/tutorial/docs/tutorial_8_gossipsub_event_callback.md b/tutorial/docs/tutorial_8_gossipsub_event_callback.md index c59ca0e..5a9b2e2 100644 --- a/tutorial/docs/tutorial_8_gossipsub_event_callback.md +++ b/tutorial/docs/tutorial_8_gossipsub_event_callback.md @@ -36,6 +36,8 @@ int main() { printf("=== Tutorial 8: GossipSub - Event Callback Messages ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create two nodes with GossipSub enabled diff --git a/tutorial/docs/tutorial_9_service_discovery.md b/tutorial/docs/tutorial_9_service_discovery.md index 4e95b33..323ad23 100644 --- a/tutorial/docs/tutorial_9_service_discovery.md +++ b/tutorial/docs/tutorial_9_service_discovery.md @@ -37,6 +37,8 @@ int main() { printf("=== Tutorial 9: Service Discovery ===\n\n"); + setLogLevel(LogLevel::Fatal); + ``` ## Step 1: Create a bootstrap node diff --git a/tutorial/tutorial_0_introduction.cpp b/tutorial/tutorial_0_introduction.cpp index 433215f..1b3fb8c 100644 --- a/tutorial/tutorial_0_introduction.cpp +++ b/tutorial/tutorial_0_introduction.cpp @@ -40,8 +40,30 @@ /// operation fails, they print a useful error message to `stderr` and return /// `1`. Successful tutorials print progress to `stdout` and return `0`. /// -/// The `stdout` stream can be noisy because logs from the wrapped C binding -/// are also included. This is tracked in [issue #79](https://github.com/logos-co/logos-libp2p-module/issues/79). +/// ## Controlling libp2p Logs +/// +/// The wrapped libp2p binding can emit runtime logs. Tutorials set the log +/// level to `LogLevel::Fatal` by default so `stdout` only shows the tutorial's +/// own progress messages during normal runs. Choose another level such as +/// `LogLevel::Info`, `LogLevel::Debug`, or `LogLevel::Trace` when you need more +/// detail while debugging: +/// +/// ```cpp +/// setLogLevel(LogLevel::Debug); +/// // ... or +/// Libp2pModuleImpl::setLogLevel(LogLevel::Debug); +/// ``` +/// +/// Log levels are inclusive minimum thresholds: `LogLevel::Trace` emits trace +/// and above, `LogLevel::Debug` emits debug and above, and so on. +/// `LogLevel::None` is the lowest threshold, so it emits all logs; it does not +/// disable logging. Use `LogLevel::Fatal` for the quietest built-in threshold. +/// +/// In your own application, `LogLevel::Error` is often a useful default. +/// It keeps normal output quiet while still surfacing conditions +/// that may indicate libp2p is misbehaving or that your integration code needs an +/// adjustment. Some error logs describe remote-peer behavior, retries, or +/// recoverable internal state, so they may not require any action from your side. /// /// ## Convert JSON Values Explicitly /// @@ -79,6 +101,9 @@ int main() { printf("=== Tutorial 0: Introduction and Common Patterns ===\n\n"); + // Silence logs from wrapped library. + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create and start a node /// /// Even the first real operation returns a result. Check it before moving on. @@ -166,3 +191,17 @@ int main() /// ```bash /// nix --extra-experimental-features 'nix-command flakes' develop --command ./tutorial/build_tutorials.sh /// ``` + +/// ## Exercise: Enable libp2p debug logs +/// +/// Change this tutorial's log level from `LogLevel::None` to +/// `LogLevel::Debug`: +/// +/// ```cpp +/// setLogLevel(LogLevel::Debug); +/// ``` +/// +/// Compile the tutorial binaries again, using the same command from above. +/// +/// Run tutorial 0 again. You should now see libp2p debug logs in `stdout` +/// alongside the tutorial's own progress messages. diff --git a/tutorial/tutorial_10_peerstore.cpp b/tutorial/tutorial_10_peerstore.cpp index 99a9848..f6a5200 100644 --- a/tutorial/tutorial_10_peerstore.cpp +++ b/tutorial/tutorial_10_peerstore.cpp @@ -26,6 +26,8 @@ int main() { printf("=== Tutorial 10: Peer Store Management ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create two nodes /// /// The peer store is automatically available on any started node. diff --git a/tutorial/tutorial_11_circuit_relay.cpp b/tutorial/tutorial_11_circuit_relay.cpp index 436d4ca..6748d97 100644 --- a/tutorial/tutorial_11_circuit_relay.cpp +++ b/tutorial/tutorial_11_circuit_relay.cpp @@ -44,6 +44,8 @@ int main() { printf("=== Tutorial 11: Circuit Relay ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create three nodes /// /// - **Relay** (port 9890): publicly reachable, `circuitRelay: true` diff --git a/tutorial/tutorial_1_node_lifecycle.cpp b/tutorial/tutorial_1_node_lifecycle.cpp index f4d4618..0208211 100644 --- a/tutorial/tutorial_1_node_lifecycle.cpp +++ b/tutorial/tutorial_1_node_lifecycle.cpp @@ -22,10 +22,15 @@ #include #include "plugin.h" -/// The main class we work with is `Libp2pModuleImpl`. Let's create one with -/// default options: int main() { + printf("=== Tutorial 1: Creating and Starting a libp2p Node ===\n\n"); + + setLogLevel(LogLevel::Fatal); + +/// The main class we work with is `Libp2pModuleImpl`. Let's create one with +/// default options: + // Create a libp2p node with default configuration. // By default it listens on 127.0.0.1 with a random port (tcp/0). Libp2pModuleImpl node; @@ -95,6 +100,8 @@ int main() node.stop(); printf("Node stopped\n"); + printf("\n=== Tutorial 1 Complete ===\n"); + return 0; } diff --git a/tutorial/tutorial_2_custom_config.cpp b/tutorial/tutorial_2_custom_config.cpp index 925c9cc..c7a3cf2 100644 --- a/tutorial/tutorial_2_custom_config.cpp +++ b/tutorial/tutorial_2_custom_config.cpp @@ -34,6 +34,10 @@ int main() { + printf("=== Tutorial 2: Custom Node Configuration ===\n\n"); + + setLogLevel(LogLevel::Fatal); + /// ## Method 1: Configure via C++ struct /// /// The most explicit way to configure a node is by constructing @@ -144,6 +148,20 @@ int main() return 0; } +/// ## Summary +/// +/// In this tutorial you learned: +/// - How to configure a node with a fixed port +/// - How to control connection limits +/// - How to pass options via C++ struct or JSON +/// - How to verify the node's actual bound addresses + +/// ## Run tutorial +/// +/// ```bash +/// ./build/tutorial/tutorial_2_custom_config +/// ``` + /// ## Exercise: Try different configurations /// /// Experiment with these variations: @@ -159,17 +177,3 @@ int main() /// "/ip4/0.0.0.0/tcp/9094" /// }; /// ``` - -/// ## Summary -/// -/// In this tutorial you learned: -/// - How to configure a node with a fixed port -/// - How to control connection limits -/// - How to pass options via C++ struct or JSON -/// - How to verify the node's actual bound addresses - -/// ## Run tutorial -/// -/// ```bash -/// ./build/tutorial/tutorial_2_custom_config -/// ``` diff --git a/tutorial/tutorial_3_connecting_peers.cpp b/tutorial/tutorial_3_connecting_peers.cpp index f975ba7..721fc13 100644 --- a/tutorial/tutorial_3_connecting_peers.cpp +++ b/tutorial/tutorial_3_connecting_peers.cpp @@ -43,6 +43,8 @@ int main() { printf("=== Tutorial 3: Connecting Peers ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create and start two nodes /// /// We create two nodes. Node A listens on port 9190, Node B on port 9191. diff --git a/tutorial/tutorial_4_custom_protocol.cpp b/tutorial/tutorial_4_custom_protocol.cpp index d14fe2f..c0fe0a7 100644 --- a/tutorial/tutorial_4_custom_protocol.cpp +++ b/tutorial/tutorial_4_custom_protocol.cpp @@ -54,6 +54,8 @@ int main() { printf("=== Tutorial 4: Custom Protocol Handlers ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create and start two nodes Libp2pModuleOptions optsA, optsB; optsA.addrs = {"/ip4/127.0.0.1/tcp/9290"}; diff --git a/tutorial/tutorial_5_kademlia_basics.cpp b/tutorial/tutorial_5_kademlia_basics.cpp index 0606a3e..3a6b9b4 100644 --- a/tutorial/tutorial_5_kademlia_basics.cpp +++ b/tutorial/tutorial_5_kademlia_basics.cpp @@ -39,6 +39,8 @@ int main() { printf("=== Tutorial 5: Kademlia DHT Basics ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create two nodes /// /// We need at least two nodes to demonstrate DHT operations. In a diff --git a/tutorial/tutorial_6_kademlia_providers.cpp b/tutorial/tutorial_6_kademlia_providers.cpp index c73fc5e..98cd59a 100644 --- a/tutorial/tutorial_6_kademlia_providers.cpp +++ b/tutorial/tutorial_6_kademlia_providers.cpp @@ -34,6 +34,8 @@ int main() { printf("=== Tutorial 6: Kademlia Provider Records ===\n\n"); + + setLogLevel(LogLevel::Fatal); /// ## Step 1: Create two peers Libp2pModuleOptions optsA, optsB; diff --git a/tutorial/tutorial_7_gossipsub_polling.cpp b/tutorial/tutorial_7_gossipsub_polling.cpp index a44a6cf..06c7f35 100644 --- a/tutorial/tutorial_7_gossipsub_polling.cpp +++ b/tutorial/tutorial_7_gossipsub_polling.cpp @@ -36,6 +36,8 @@ int main() { printf("=== Tutorial 7: GossipSub - Polling for Messages ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create two nodes with GossipSub enabled /// /// GossipSub is enabled by default (`mountGossipsub: true`). diff --git a/tutorial/tutorial_8_gossipsub_event_callback.cpp b/tutorial/tutorial_8_gossipsub_event_callback.cpp index 679471e..f16e1a7 100644 --- a/tutorial/tutorial_8_gossipsub_event_callback.cpp +++ b/tutorial/tutorial_8_gossipsub_event_callback.cpp @@ -35,6 +35,8 @@ int main() { printf("=== Tutorial 8: GossipSub - Event Callback Messages ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create two nodes with GossipSub enabled Libp2pModuleOptions optsA, optsB; optsA.addrs = {"/ip4/127.0.0.1/tcp/9600"}; diff --git a/tutorial/tutorial_9_service_discovery.cpp b/tutorial/tutorial_9_service_discovery.cpp index 278270b..dfe8143 100644 --- a/tutorial/tutorial_9_service_discovery.cpp +++ b/tutorial/tutorial_9_service_discovery.cpp @@ -36,6 +36,8 @@ int main() { printf("=== Tutorial 9: Service Discovery ===\n\n"); + setLogLevel(LogLevel::Fatal); + /// ## Step 1: Create a bootstrap node /// /// The bootstrap is a well-known node that all peers connect to.