diff options
| author | namilsk <namilsk@namilsk.tech> | 2026-03-07 00:14:24 +0300 |
|---|---|---|
| committer | namilsk <namilsk@namilsk.tech> | 2026-03-07 00:14:24 +0300 |
| commit | 3b3bcf1306857e0607010d657a1c9cc0b846d977 (patch) | |
| tree | d0b9e3f9b506dbe9f87c6fb3e7acb533ea69901d /init/src/log.rs | |
| parent | 772093279e1dd162a47e2dfe50d9a9ae0192d750 (diff) | |
Autofmt, updated `TODO.md`
Diffstat (limited to 'init/src/log.rs')
| -rw-r--r-- | init/src/log.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/init/src/log.rs b/init/src/log.rs index 207394b..c5e2ff2 100644 --- a/init/src/log.rs +++ b/init/src/log.rs @@ -6,13 +6,12 @@ const LOG_FILE_PATH: &str = "/var/log/vigil.log"; static LOG_FILE: Mutex<Option<std::fs::File>> = Mutex::new(None); -/// Инициализирует файл логирования. Должен вызываться один раз при старте. pub fn init_logging() -> Result<(), Box<dyn std::error::Error>> { let file = OpenOptions::new() .create(true) .append(true) .open(LOG_FILE_PATH)?; - + let mut guard = LOG_FILE.lock().map_err(|e| e.to_string())?; *guard = Some(file); Ok(()) @@ -23,7 +22,7 @@ fn write_to_log(message: &str) { Ok(g) => g, Err(poisoned) => poisoned.into_inner(), }; - + if let Some(ref mut file) = *guard { let _ = writeln!(file, "{}", message); let _ = file.flush(); |
