fstdout_logger/examples/
mod.rs1use colored::Colorize;
2
3pub fn show_colored_log_examples() {
5 println!("=== COLORED LOG EXAMPLES ===");
6
7 let timestamp = chrono::Local::now().format("%H:%M:%S");
8 let colored_time = timestamp.to_string().bright_black();
9
10 println!(
11 "[{} {}] This is a TRACE message",
12 colored_time,
13 "TRACE".normal()
14 );
15
16 println!(
17 "[{} {}] This is a DEBUG message",
18 colored_time,
19 "DEBUG".green()
20 );
21
22 println!(
23 "[{} {}] This is an INFO message",
24 colored_time,
25 "INFO".blue().bold()
26 );
27
28 println!(
29 "[{} {}] This is a WARNING message",
30 colored_time,
31 "WARN".yellow().bold()
32 );
33
34 println!(
35 "[{} {}] This is an ERROR message",
36 colored_time,
37 "ERROR".red().bold()
38 );
39
40 println!(" ");
41}
42
43pub fn show_plain_log_examples() {
48 println!("=== PLAIN TEXT LOG EXAMPLES ===");
49
50 let timestamp = chrono::Local::now().format("%H:%M:%S");
51
52 println!("[{timestamp} TRACE] This is a TRACE message");
53
54 println!("[{timestamp} DEBUG] This is a DEBUG message");
55
56 println!("[{timestamp} INFO] This is an INFO message");
57
58 println!("[{timestamp} WARN] This is a WARNING message");
59
60 println!("[{timestamp} ERROR] This is an ERROR message");
61
62 println!(" ");
63}
64
65pub fn show_file_info_examples() {
71 println!("=== LOGS WITH FILE INFO ===");
72
73 let timestamp = chrono::Local::now().format("%H:%M:%S");
74 let file = "examples/show_colors.rs";
75 let line = 42;
76
77 println!(
78 "[{} {} {}:{}] This is a log message with file info",
79 timestamp.to_string().bright_black(),
80 "INFO".blue().bold(),
81 file.bright_black(),
82 line
83 );
84
85 println!("=== LOGS WITHOUT FILE INFO ===");
86
87 println!(
88 "[{} {}] This is a log message without file info",
89 timestamp.to_string().bright_black(),
90 "INFO".blue().bold()
91 );
92
93 println!(" ");
94}