Don't unwrap in debug code

This commit is contained in:
hodasemi 2023-04-11 08:50:43 +02:00
parent 872c858f9e
commit b4d6644c48

View file

@ -17,16 +17,16 @@ macro_rules! load_function_ptrs {
fn log(msg: impl ToString) { fn log(msg: impl ToString) {
use std::io::Write; use std::io::Write;
let home = std::env::var("HOME").unwrap(); if let Ok(home) = std::env::var("HOME") {
let log_file = format!("{}/rf2_vk_hud.log", home);
let log_file = format!("{}/rf2_vk_hud.log", home); if let Ok(mut file) = std::fs::OpenOptions::new()
.append(true)
if let Ok(mut file) = std::fs::OpenOptions::new() .create(true)
.append(true) .open(&log_file)
.create(true) {
.open(&log_file) if let Err(_) = file.write_all(format!("{}\n", msg.to_string()).as_bytes()) {}
{ }
if let Err(_) = file.write_all(format!("{}\n", msg.to_string()).as_bytes()) {}
} }
} }