Skip to content

Commit 0a7548f

Browse files
Added colorful outputs to the log files
1 parent 3e9cdae commit 0a7548f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ repository = "https://github.com/CodeF0x/ffzap"
1313
chrono = "0.4.39"
1414
clap = { version = "4.5.20", features = ["derive"] }
1515
dirs = "6.0.0"
16-
indicatif = "0.17.9"
16+
indicatif = "0.17.9"
17+
colored = "3.0.0"

src/logger.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::fs::File;
44
use std::io::Write;
55
use std::path::{Display, PathBuf};
66
use std::sync::{Arc, Mutex, MutexGuard};
7+
use colored::*;
78

89
pub(crate) struct Logger {
910
progress: Arc<Progress>,
@@ -27,8 +28,9 @@ impl Logger {
2728

2829
pub(crate) fn log_info(&self, line: String, thread: u16, print: bool) {
2930
let line = format!("[INFO in THREAD {thread}] -- {line}\n");
31+
let blue_line = line.bright_blue().to_string();
3032

31-
self.write_to_log(&line);
33+
self.write_to_log(&blue_line);
3234

3335
if print {
3436
self.print(line);
@@ -37,11 +39,11 @@ impl Logger {
3739

3840
pub(crate) fn log_error(&self, line: String, thread: u16, print: bool) {
3941
let line = format!("[ERROR in THREAD {thread} -- {line}\n");
40-
41-
self.write_to_log(&line);
42+
let red_line = line.bright_red().to_string();
43+
self.write_to_log(&red_line);
4244

4345
if print {
44-
self.print(line);
46+
self.print(red_line);
4547
}
4648
}
4749

0 commit comments

Comments
 (0)