hotfix(logging): let logging fail silently while testing

This commit is contained in:
Kunal Mohan 2021-05-07 16:50:58 +05:30
parent d3a38763cb
commit 61e8d09151
2 changed files with 7 additions and 7 deletions

View file

@ -1261,7 +1261,9 @@ impl vte::Perform for Grid {
self.insert_character_at_cursor_position(EMPTY_TERMINAL_CHARACTER);
}
} else {
let _ = debug_log_to_file(format!("Unhandled csi: {}->{:?}", c, params));
let result = debug_log_to_file(format!("Unhandled csi: {}->{:?}", c, params));
#[cfg(not(test))]
result.unwrap();
}
}

View file

@ -10,14 +10,12 @@ use std::{
use crate::os_input_output::set_permissions;
use crate::utils::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
pub fn atomic_create_file(file_name: &Path) {
pub fn atomic_create_file(file_name: &Path) -> io::Result<()> {
let _ = fs::OpenOptions::new()
.append(true)
.create(true)
.open(file_name)
.unwrap();
#[cfg(not(test))]
set_permissions(file_name).unwrap();
.open(file_name)?;
set_permissions(file_name)
}
pub fn atomic_create_dir(dir_name: &Path) -> io::Result<()> {
@ -42,7 +40,7 @@ pub fn debug_log_to_file(mut message: String) -> io::Result<()> {
}
pub fn debug_log_to_file_without_newline(message: String) -> io::Result<()> {
atomic_create_file(&*ZELLIJ_TMP_LOG_FILE);
atomic_create_file(&*ZELLIJ_TMP_LOG_FILE)?;
let mut file = fs::OpenOptions::new()
.append(true)
.open(&*ZELLIJ_TMP_LOG_FILE)?;