With the latest fern, syslog can be a config option instead of a build flag

This commit is contained in:
Daniel García
2019-03-29 20:27:20 +01:00
parent d9406b0095
commit c5832f2b30
4 changed files with 64 additions and 61 deletions

View File

@ -90,19 +90,19 @@ fn init_logging() -> Result<(), fern::InitError> {
if let Some(log_file) = CONFIG.log_file() {
logger = logger.chain(fern::log_file(log_file)?);
}
#[cfg(not(windows))] {
if cfg!(feature="enable_syslog") || CONFIG.use_syslog() {
logger = chain_syslog(logger);
}
}
logger = chain_syslog(logger);
logger.apply()?;
Ok(())
}
#[cfg(not(feature = "enable_syslog"))]
fn chain_syslog(logger: fern::Dispatch) -> fern::Dispatch {
logger
}
#[cfg(feature = "enable_syslog")]
#[cfg(not(windows))]
fn chain_syslog(logger: fern::Dispatch) -> fern::Dispatch {
let syslog_fmt = syslog::Formatter3164 {
facility: syslog::Facility::LOG_USER,