From 7d19364a1d9688a2b62033cae8e62a785a58c1be Mon Sep 17 00:00:00 2001
From: bgallois <benjamin@gallois.cc>
Date: Thu, 28 Nov 2024 12:45:19 +0100
Subject: [PATCH] add log for distance oracle in main binary

---
 node/src/cli.rs     | 8 +++++---
 node/src/command.rs | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/node/src/cli.rs b/node/src/cli.rs
index a45b8d64c..4a29ae0c0 100644
--- a/node/src/cli.rs
+++ b/node/src/cli.rs
@@ -132,14 +132,16 @@ pub struct Completion {
 #[cfg(feature = "distance-oracle")]
 #[derive(Debug, clap::Parser)]
 pub struct DistanceOracle {
+    /// Saving path.
     #[clap(short = 'd', long, default_value = "/tmp/duniter/chains/gdev/distance")]
     pub evaluation_result_dir: String,
-    /// Number of seconds between two evaluations (oneshot if absent)
+    /// Number of seconds between two evaluations (oneshot if absent).
     #[clap(short = 'i', long)]
     pub interval: Option<u64>,
-    /// Node used for fetching state
+    /// Node used for fetching state.
     #[clap(short = 'u', long, default_value = "ws://127.0.0.1:9944")]
     pub rpc_url: String,
+    /// Sets the logging level (e.g., debug, error, info, trace, warn).
     #[clap(short = 'l', long, default_value = "info")]
-    log: log::LevelFilter,
+    pub log: String,
 }
diff --git a/node/src/command.rs b/node/src/command.rs
index 0189fe170..58eabb014 100644
--- a/node/src/command.rs
+++ b/node/src/command.rs
@@ -285,6 +285,9 @@ pub fn run() -> sc_cli::Result<()> {
         }
         #[cfg(feature = "distance-oracle")]
         Some(Subcommand::DistanceOracle(cmd)) => sc_cli::build_runtime()?.block_on(async move {
+            let mut builder = sc_cli::LoggerBuilder::new("");
+            builder.with_profiling(sc_cli::TracingReceiver::Log.into(), cmd.log.clone());
+            builder.init()?;
             let client = distance_oracle::api::client(&cmd.rpc_url).await;
 
             let settings = distance_oracle::Settings {
-- 
GitLab