summaryrefslogtreecommitdiffstats
path: root/src/log.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-03-08 22:11:11 +0100
committerqkzk <qu3nt1n@gmail.com>2023-03-08 22:11:11 +0100
commit1dbc6963eeb23f769ddd43299a95880cdaf26049 (patch)
treef59bb73262eabebc8229454a8ee3d25f762749db /src/log.rs
parent36113f1574dfeab949000fd26543b3e78b9323f8 (diff)
action log every file tree modification. Display the logs with Alt+l.
Diffstat (limited to 'src/log.rs')
-rw-r--r--src/log.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/log.rs b/src/log.rs
index a0fce1e..23166c5 100644
--- a/src/log.rs
+++ b/src/log.rs
@@ -1,7 +1,8 @@
use log4rs;
-use crate::constant_strings_paths::LOG_CONFIG_PATH;
+use crate::constant_strings_paths::{ACTION_LOG_PATH, LOG_CONFIG_PATH};
use crate::fm_error::FmResult;
+use crate::utils::extract_last_lines_poorly;
pub fn set_loggers() -> FmResult<()> {
log4rs::init_file(
@@ -10,3 +11,10 @@ pub fn set_loggers() -> FmResult<()> {
)?;
Ok(())
}
+
+/// Returns the last line of the log file.
+pub fn read_log(line_nr: usize) -> FmResult<Vec<String>> {
+ let log_path = shellexpand::tilde(ACTION_LOG_PATH).to_string();
+ let content = std::fs::read_to_string(log_path)?;
+ Ok(extract_last_lines_poorly(content, line_nr))
+}