Skip to content

Commit 8799abb

Browse files
Merge pull request #209 from WithSecureLabs/feat/logging_improvements
feat: improved logging
2 parents d936304 + 260b697 commit 8799abb

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chainsaw"
3-
version = "2.10.3"
3+
version = "2.10.4"
44
repository = "https://github.com/WithSecureLabs/chainsaw"
55
description = "Rapidly Search and Hunt Through Windows Forensic Artefacts"
66
authors = ["James Dorgan <[email protected]>","Alex Kornitzer <[email protected]>"]

src/cli.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ const TICK_SETTINGS: (&str, u64) = ("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ ", 80);
3434
#[cfg(windows)]
3535
const TICK_SETTINGS: (&str, u64) = (r"-\|/-", 200);
3636

37-
pub fn init_progress_bar(size: u64, msg: String, verbose: bool) -> indicatif::ProgressBar {
37+
pub fn init_progress_bar(
38+
size: u64,
39+
msg: String,
40+
verbose: bool,
41+
prefix: String,
42+
) -> indicatif::ProgressBar {
3843
let pb = ProgressBar::new(size);
3944
if verbose {
4045
pb.set_draw_target(ProgressDrawTarget::hidden());
@@ -48,7 +53,13 @@ pub fn init_progress_bar(size: u64, msg: String, verbose: bool) -> indicatif::Pr
4853
}
4954
pb.set_style(
5055
ProgressStyle::default_bar()
51-
.template("[+] {msg}: [{bar:40}] {pos}/{len} {spinner}")
56+
.template(
57+
format!(
58+
"{{msg}}[+] {} [{{bar:40}}] {{pos}}/{{len}} {{spinner}} [{{elapsed_precise}}]",
59+
prefix
60+
)
61+
.as_str(),
62+
)
5263
.expect("could not set template")
5364
.tick_chars(TICK_SETTINGS.0)
5465
.progress_chars("=>-"),

src/hunt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl Hunter {
793793
Err(e) => {
794794
if self.inner.skip_errors {
795795
cs_eyellowln!(
796-
"[!] failed to parse document '{}' - {}\n",
796+
"[!] failed to parse document '{}' - {} - use --skip-errors to continue...\n",
797797
file.display(),
798798
e
799799
);

src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,12 +723,13 @@ fn run() -> Result<()> {
723723
let mut detections = vec![];
724724
let pb = cli::init_progress_bar(
725725
files.len() as u64,
726-
"Hunting".to_string(),
726+
"".to_string(),
727727
args.verbose != 0,
728+
"Hunting".to_string(),
728729
);
729730
for file in &files {
730731
cs_debug!("[*] Hunting through file - {}", file.display());
731-
pb.tick();
732+
pb.set_message(format!("[+] Current Artifact: {}\n", file.display()));
732733
let cache = if cache {
733734
match tempfile::tempfile() {
734735
Ok(f) => Some(f),
@@ -740,7 +741,7 @@ fn run() -> Result<()> {
740741
None
741742
};
742743
let scratch = hunter.hunt(file, &cache).with_context(|| {
743-
format!("Failed to hunt through file '{}'", file.to_string_lossy())
744+
format!("Failed to hunt through file '{}' (Use --skip-errors to continue processing)", file.to_string_lossy())
744745
})?;
745746
hits += scratch.iter().map(|d| d.hits.len()).sum::<usize>();
746747
documents += scratch.len();

0 commit comments

Comments
 (0)