Skip to main content

rust_nrm/utils/
logger.rs

1use colored::Colorize;
2
3pub struct Logger;
4
5impl Logger {
6    pub fn info(message: &str) {
7        println!(
8            "{} {}",
9            format!(" INFO ").white().on_blue(),
10            message.blue()
11        );
12    }
13
14    pub fn info_bold(message: &str) {
15        println!(
16            "{} {}",
17            format!(" INFO ").white().on_blue(),
18            message.blue().bold()
19        );
20    }
21
22    pub fn success(message: &str) {
23        println!(
24            "{} {}",
25            format!(" SUCCESS ").white().on_green(),
26            message.green()
27        );
28    }
29
30    pub fn success_bold(message: &str) {
31        println!(
32            "{} {}",
33            format!(" SUCCESS ").white().on_green(),
34            message.green().bold()
35        );
36    }
37
38    pub fn error(message: &str) {
39        println!(
40            "{} {}",
41            format!(" ERROR ").white().on_red(),
42            message.red()
43        );
44    }
45
46    pub fn error_bold(message: &str) {
47        println!(
48            "{} {}",
49            format!(" ERROR ").white().on_red(),
50            message.red().bold()
51        );
52    }
53
54    pub fn list(message: &str) {
55        println!(
56            "{} {}",
57            format!(" LIST ").white().on_magenta(),
58            message.magenta().bold()
59        );
60    }
61
62    pub fn custom(label: &str, message: &str, bg_color: colored::Color, fg_color: colored::Color) {
63        println!(
64            "{} {}",
65            format!(" {} ", label).white().on_color(bg_color),
66            message.color(fg_color)
67        );
68    }
69
70    pub fn custom_bold(label: &str, message: &str, bg_color: colored::Color, fg_color: colored::Color) {
71        println!(
72            "{} {}",
73            format!(" {} ", label).white().on_color(bg_color),
74            message.color(fg_color).bold()
75        );
76    }
77}