Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Make sure to print early errors
◌ CI pending Lorenz Leutgeb committed 9 months ago
commit 6f4528c97ba164b62cbf246750449ca0f9b0f8ac
parent 7d2f0e387c66f3f24b94673a2de9589407e2f946
1 pending (1 total) View logs
1 file changed +14 -6
modified crates/radicle-node/src/main.rs
@@ -86,12 +86,11 @@ impl Options {
}

fn execute() -> anyhow::Result<()> {
-
    let home = profile::home()?;
-
    let options = Options::from_env()?;
-
    let config = options.config.unwrap_or_else(|| home.config());
-
    let mut config = profile::Config::load(&config)?;
-

-
    let level = options.log.unwrap_or_else(|| config.node.log.into());
+
    // Before we do anything else, we choose a default log level and initialize
+
    // logging. The simple reason is that the next thing we want to do is read
+
    // configuration (which contains the actual log level to use), but note that
+
    // *this might fail* in which case *the user expects a log output*.
+
    let level = log::Level::Error;

    let logger = {
        let journal = {
@@ -115,6 +114,15 @@ fn execute() -> anyhow::Result<()> {
    log::set_boxed_logger(logger).expect("no other logger should have been set already");
    log::set_max_level(level.to_level_filter());

+
    let home = profile::home()?;
+
    let options = Options::from_env()?;
+
    let config = options.config.unwrap_or_else(|| home.config());
+
    let mut config = profile::Config::load(&config)?;
+

+
    let level = options.log.unwrap_or_else(|| config.node.log.into());
+
    // Only now the log level obtained via configuration becomes active.
+
    log::set_max_level(level.to_level_filter());
+

    log::info!(target: "node", "Starting node..");
    log::info!(target: "node", "Version {} ({})", env!("RADICLE_VERSION"), env!("GIT_HEAD"));
    log::info!(target: "node", "Unlocking node keystore..");