Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 9, 2024
1 parent 60d8d14 commit db95c1c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/cli/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ impl Logs {
lines.take(self.n).collect_vec()
};
lines.into_iter().fold(vec![], |mut acc, line| {
match regex!(r"^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (.*)$")
.captures(&line)
{
match regex!(r"^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (.*)$").captures(&line) {
Some(caps) => {
let date = caps.get(1).unwrap().as_str().to_string();
let msg = caps.get(2).unwrap().as_str().to_string();
Expand All @@ -77,7 +75,10 @@ impl Logs {
} else {
log_lines.take(self.n).collect_vec()
};
let log_lines = log_lines.into_iter().rev().collect_vec();
let log_lines = log_lines
.into_iter()
.sorted_by_cached_key(|l| l.0.to_string())
.collect_vec();

for (date, name, msg) in log_lines {
println!("{} {} {}", date, name, msg);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::Result;
use clap::Parser;

mod daemon;
mod logs;
mod run;
mod start;
mod logs;

#[derive(Debug, clap::Parser)]
struct Cli {
Expand Down
7 changes: 2 additions & 5 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ pub static PITCHFORK_LOG_FILE_LEVEL: Lazy<log::LevelFilter> =
Lazy::new(|| var_log_level("PITCHFORK_LOG_FILE_LEVEL").unwrap_or(*PITCHFORK_LOG));
pub static PITCHFORK_LOGS_DIR: Lazy<PathBuf> =
Lazy::new(|| var_path("PITCHFORK_LOGS_DIR").unwrap_or(PITCHFORK_STATE_DIR.join("logs")));
pub static PITCHFORK_LOG_FILE: Lazy<PathBuf> = Lazy::new(|| {
PITCHFORK_LOGS_DIR
.join("pitchfork")
.join("pitchfork.log")
});
pub static PITCHFORK_LOG_FILE: Lazy<PathBuf> =
Lazy::new(|| PITCHFORK_LOGS_DIR.join("pitchfork").join("pitchfork.log"));
pub static PITCHFORK_EXEC: Lazy<bool> = Lazy::new(|| var_true("PITCHFORK_EXEC"));

pub static IPC_SOCK_DIR: Lazy<PathBuf> = Lazy::new(|| PITCHFORK_STATE_DIR.join("sock"));
Expand Down

0 comments on commit db95c1c

Please sign in to comment.