Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
node/log: Define syslog identifier
Merged lorenz opened 7 months ago

The argument passed to fn logger would only be used as a fallback. Make it required to pass an identifier, as this is a good practice.

2 files changed +5 -7 ee49e287 474b9795
modified crates/radicle-node/src/main.rs
@@ -338,7 +338,8 @@ fn initialize_logging(options: &LogOptions) -> Result<(), Box<dyn std::error::Er
                    return Err(Box::new(JournalError::NotConnected));
                }

-
                logger::<&str, &str, _>("radicle-node".to_string(), []).map_err(Box::new)?
+
                const SYSLOG_IDENTIFIER: &str = "radicle-node";
+
                logger::<&str, &str, _>(SYSLOG_IDENTIFIER.to_string(), []).map_err(Box::new)?
            }
            Logger::Radicle => Box::new(radicle::logger::Logger::new(level)),
        }
modified crates/radicle-systemd/src/journal.rs
@@ -1,11 +1,8 @@
-
use systemd_journal_logger::{connected_to_journal, current_exe_identifier, JournalLog};
+
use systemd_journal_logger::{connected_to_journal, JournalLog};

/// If the current process is directly connected to the systemd journal,
/// return a logger that will write to it.
-
pub fn logger<K, V, I>(
-
    default_identifier: String,
-
    extra_fields: I,
-
) -> std::io::Result<Box<dyn log::Log>>
+
pub fn logger<K, V, I>(identifier: String, extra_fields: I) -> std::io::Result<Box<dyn log::Log>>
where
    I: IntoIterator<Item = (K, V)>,
    K: AsRef<str>,
@@ -13,7 +10,7 @@ where
{
    Ok(Box::new(
        JournalLog::new()?
-
            .with_syslog_identifier(current_exe_identifier().unwrap_or(default_identifier))
+
            .with_syslog_identifier(identifier)
            .with_extra_fields(extra_fields),
    ))
}