mirror of
https://github.com/dani-garcia/vaultwarden
synced 2024-11-25 13:20:23 +00:00
Merge pull request #3909 from tobiasmboelz/reopen-log-file
Reopen log file on SIGHUP
This commit is contained in:
commit
18fbc1ccf6
3 changed files with 24 additions and 2 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -878,7 +878,9 @@ version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee"
|
checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
|
"reopen",
|
||||||
"syslog",
|
"syslog",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2348,6 +2350,17 @@ version = "0.7.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reopen"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ff42cec3acf85845f5b18b3cbb7fec619ccbd4a349f6ecbe1c62ab46d4d98293"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"libc",
|
||||||
|
"signal-hook",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.11.20"
|
version = "0.11.20"
|
||||||
|
|
|
@ -41,7 +41,7 @@ syslog = "6.1.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Logging
|
# Logging
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
fern = { version = "0.6.2", features = ["syslog-6"] }
|
fern = { version = "0.6.2", features = ["syslog-6", "reopen-1"] }
|
||||||
tracing = { version = "0.1.37", features = ["log"] } # Needed to have lettre and webauthn-rs trace logging to work
|
tracing = { version = "0.1.37", features = ["log"] } # Needed to have lettre and webauthn-rs trace logging to work
|
||||||
|
|
||||||
# A `dotenv` implementation for Rust
|
# A `dotenv` implementation for Rust
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -326,7 +326,16 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(log_file) = CONFIG.log_file() {
|
if let Some(log_file) = CONFIG.log_file() {
|
||||||
logger = logger.chain(fern::log_file(log_file)?);
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
logger = logger.chain(fern::log_file(log_file)?);
|
||||||
|
}
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
const SIGHUP: i32 = tokio::signal::unix::SignalKind::hangup().as_raw_value();
|
||||||
|
let path = Path::new(&log_file);
|
||||||
|
logger = logger.chain(fern::log_reopen1(path, [SIGHUP])?);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|
Loading…
Reference in a new issue