mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-05-29 23:13:57 +00:00
With the latest fern, syslog can be a config option instead of a build flag
This commit is contained in:
parent
d9406b0095
commit
c5832f2b30
4 changed files with 64 additions and 61 deletions
|
@ -275,6 +275,8 @@ make_config! {
|
|||
log_mounts: bool, true, def, false;
|
||||
/// Enable extended logging
|
||||
extended_logging: bool, false, def, true;
|
||||
/// Enable the log to output to Syslog
|
||||
use_syslog: bool, false, def, false;
|
||||
/// Log file path
|
||||
log_file: String, false, option;
|
||||
/// Log level
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue