node/log: Define syslog identifier
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.
This commit is contained in:
parent
ee49e28766
commit
474b97950b
|
|
@ -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)),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue