Reopen log file on SIGHUP

This commit is contained in:
Tobias Bölz
2023-09-22 17:03:41 +02:00
committed by Mathijs van Veluw
parent ff8db4fd78
commit 66a7baa67c
3 changed files with 26 additions and 2 deletions

View File

@ -326,7 +326,16 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> {
}
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 = 1;
let path = Path::new(&log_file);
logger = logger.chain(fern::log_reopen1(path, [SIGHUP])?);
}
}
#[cfg(not(windows))]