tools: file logger: use option struct to control behavior

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2020-10-15 17:49:18 +02:00
committed by Dietmar Maurer
parent 400c568f8e
commit c0df91f8bd
2 changed files with 46 additions and 14 deletions

View File

@ -21,7 +21,7 @@ use proxmox::tools::fs::{create_path, open_file_locked, replace_file, CreateOpti
use super::UPID;
use crate::tools::logrotate::{LogRotate, LogRotateFiles};
use crate::tools::FileLogger;
use crate::tools::{FileLogger, FileLogOptions};
use crate::api2::types::Userid;
macro_rules! PROXMOX_BACKUP_VAR_RUN_DIR_M { () => ("/run/proxmox-backup") }
@ -672,7 +672,13 @@ impl WorkerTask {
println!("FILE: {:?}", path);
let logger = FileLogger::new(&path, to_stdout)?;
let logger_options = FileLogOptions {
to_stdout: to_stdout,
exclusive: true,
read: true,
..Default::default()
};
let logger = FileLogger::new(&path, logger_options)?;
nix::unistd::chown(&path, Some(backup_user.uid), Some(backup_user.gid))?;
let worker = Arc::new(Self {