aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/utils/logging.rs
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-04 13:48:19 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:48:18 +0530
commit585b225290df3e44a86555490dc9170f88148fa6 (patch)
tree3709b0cb99ea5a32d1ebc7d4fb3cae6c47dfe0c0 /src/common/utils/logging.rs
parentAdd version to socket path to avoid problems after version update (diff)
downloadsl0ppij-585b225290df3e44a86555490dc9170f88148fa6.tar.gz
sl0ppij-585b225290df3e44a86555490dc9170f88148fa6.tar.xz
sl0ppij-585b225290df3e44a86555490dc9170f88148fa6.zip
Use ZELLIJ_SOCKET_DIR env variable and make user specific tmp dir
Diffstat (limited to 'src/common/utils/logging.rs')
-rw-r--r--src/common/utils/logging.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/common/utils/logging.rs b/src/common/utils/logging.rs
index 06827bfc..d99a2428 100644
--- a/src/common/utils/logging.rs
+++ b/src/common/utils/logging.rs
@@ -4,16 +4,16 @@ use std::{
fs,
io::{self, prelude::*},
os::unix::io::RawFd,
- path::PathBuf,
+ path::{Path, PathBuf},
};
use crate::utils::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
-pub fn atomic_create_file(file_name: &str) {
+pub fn atomic_create_file(file_name: &Path) {
let _ = fs::OpenOptions::new().create(true).open(file_name);
}
-pub fn atomic_create_dir(dir_name: &str) -> io::Result<()> {
+pub fn atomic_create_dir(dir_name: &Path) -> io::Result<()> {
if let Err(e) = fs::create_dir(dir_name) {
if e.kind() == std::io::ErrorKind::AlreadyExists {
Ok(())
@@ -31,11 +31,11 @@ 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)
.create(true)
- .open(ZELLIJ_TMP_LOG_FILE)?;
+ .open(&*ZELLIJ_TMP_LOG_FILE)?;
file.write_all(message.as_bytes())
}
@@ -48,16 +48,16 @@ pub fn _debug_log_to_file_pid_3(message: String, pid: RawFd) -> io::Result<()> {
}
pub fn _delete_log_file() -> io::Result<()> {
- if fs::metadata(ZELLIJ_TMP_LOG_FILE).is_ok() {
- fs::remove_file(ZELLIJ_TMP_LOG_FILE)
+ 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)
+ if fs::metadata(&*ZELLIJ_TMP_LOG_DIR).is_ok() {
+ fs::remove_dir_all(&*ZELLIJ_TMP_LOG_DIR)
} else {
Ok(())
}
@@ -65,7 +65,7 @@ pub fn _delete_log_dir() -> io::Result<()> {
pub fn debug_to_file(message: u8, pid: RawFd) -> io::Result<()> {
let mut path = PathBuf::new();
- path.push(ZELLIJ_TMP_LOG_DIR);
+ path.push(&*ZELLIJ_TMP_LOG_DIR);
path.push(format!("zellij-{}.log", pid.to_string()));
let mut file = fs::OpenOptions::new()