diff options
| author | Thomas Linford <tlinford@users.noreply.github.com> | 2021-10-18 10:52:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-18 10:52:58 +0200 |
| commit | 76a96b538b2bb8715f9fcd2d4f02603199671b46 (patch) | |
| tree | f8e9ba23f0294187c9ff1aa38946190a613a76dd /zellij-utils/src | |
| parent | simplify .gitignore (#783) (diff) | |
| download | sl0ppij-76a96b538b2bb8715f9fcd2d4f02603199671b46.tar.gz sl0ppij-76a96b538b2bb8715f9fcd2d4f02603199671b46.tar.xz sl0ppij-76a96b538b2bb8715f9fcd2d4f02603199671b46.zip | |
logging: remove unused log functions, change log file const to new file (#779)
Diffstat (limited to 'zellij-utils/src')
| -rw-r--r-- | zellij-utils/src/consts.rs | 2 | ||||
| -rw-r--r-- | zellij-utils/src/logging.rs | 43 |
2 files changed, 4 insertions, 41 deletions
diff --git a/zellij-utils/src/consts.rs b/zellij-utils/src/consts.rs index 4e6ad9d0..bcb4ea4a 100644 --- a/zellij-utils/src/consts.rs +++ b/zellij-utils/src/consts.rs @@ -51,7 +51,7 @@ lazy_static! { pub static ref ZELLIJ_TMP_DIR: PathBuf = PathBuf::from("/tmp/zellij-".to_string() + &format!("{}", *UID)); pub static ref ZELLIJ_TMP_LOG_DIR: PathBuf = ZELLIJ_TMP_DIR.join("zellij-log"); - pub static ref ZELLIJ_TMP_LOG_FILE: PathBuf = ZELLIJ_TMP_LOG_DIR.join("log.txt"); + pub static ref ZELLIJ_TMP_LOG_FILE: PathBuf = ZELLIJ_TMP_LOG_DIR.join("zellij.log"); } pub const FEATURES: &[&str] = &[ diff --git a/zellij-utils/src/logging.rs b/zellij-utils/src/logging.rs index 6d2fe8c6..74ec5397 100644 --- a/zellij-utils/src/logging.rs +++ b/zellij-utils/src/logging.rs @@ -19,7 +19,7 @@ use crate::shared::set_permissions; pub fn configure_logger() { atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap(); atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); - atomic_create_file(&*ZELLIJ_TMP_LOG_DIR.join("zellij.log")).unwrap(); + atomic_create_file(&*ZELLIJ_TMP_LOG_FILE).unwrap(); // {n} means platform dependent newline // module is padded to exactly 25 bytes and thread is padded to be between 10 and 15 bytes. @@ -29,7 +29,7 @@ pub fn configure_logger() { let log_file = FileAppender::builder() .encoder(Box::new(PatternEncoder::new(file_pattern))) .append(true) - .build(ZELLIJ_TMP_LOG_DIR.join("zellij.log")) + .build(&*ZELLIJ_TMP_LOG_FILE) .unwrap(); // plugin appender. To be used in loggin_pipe to forward stderr output from plugins. We do some formatting @@ -39,7 +39,7 @@ pub fn configure_logger() { "{highlight({level:<6})} {message} {n}", ))) .append(true) - .build(ZELLIJ_TMP_LOG_DIR.join("zellij.log")) + .build(&*ZELLIJ_TMP_LOG_FILE) .unwrap(); // Set the default logging level to "info" and log it to zellij.log file @@ -89,43 +89,6 @@ pub fn atomic_create_dir(dir_name: &Path) -> io::Result<()> { result } -pub fn debug_log_to_file(mut message: String) -> io::Result<()> { - message.push('\n'); - debug_log_to_file_without_newline(message) -} - -pub fn debug_log_to_file_without_newline(message: String) -> io::Result<()> { - atomic_create_file(&*ZELLIJ_TMP_LOG_FILE)?; - let mut file = fs::OpenOptions::new() - .append(true) - .open(&*ZELLIJ_TMP_LOG_FILE)?; - file.write_all(message.as_bytes()) -} - -pub fn _debug_log_to_file_pid_3(message: String, pid: RawFd) -> io::Result<()> { - if pid == 3 { - debug_log_to_file(message) - } else { - Ok(()) - } -} - -pub fn _delete_log_file() -> io::Result<()> { - if fs::metadata(&*ZELLIJ_TMP_LOG_FILE).is_ok() { - fs::remove_file(&*ZELLIJ_TMP_LOG_FILE) - } else { - Ok(()) - } -} - -pub fn _delete_log_dir() -> io::Result<()> { - if fs::metadata(&*ZELLIJ_TMP_LOG_DIR).is_ok() { - fs::remove_dir_all(&*ZELLIJ_TMP_LOG_DIR) - } else { - Ok(()) - } -} - pub fn debug_to_file(message: &[u8], pid: RawFd) -> io::Result<()> { let mut path = PathBuf::new(); path.push(&*ZELLIJ_TMP_LOG_DIR); |
