stdout_only/
stdout_only.rs1use fstdout_logger::{LoggerConfig, init_stdout_logger};
11use log::{LevelFilter, debug, error, info, trace, warn};
12
13fn main() {
14 let config = LoggerConfig::builder()
16 .level(LevelFilter::Debug) .show_file_info(false) .use_colors(true) .build();
20
21 if let Err(e) = init_stdout_logger(config) {
22 eprintln!("Failed to initialize logger: {e}");
23 return;
24 }
25
26 println!("Logger initialized! Output will only appear on stdout.");
27 println!("Notice that TRACE level messages won't show because we set Debug as minimum level.");
28 println!("Also note that file and line information is hidden for cleaner output.");
29
30 trace!("This is a TRACE message - you won't see this");
32 debug!("This is a DEBUG message - visible");
33 info!("This is an INFO message - visible");
34 warn!("This is a WARNING message - visible");
35 error!("This is an ERROR message - visible");
36
37 for i in 1..=3 {
39 let value = i * 10;
40 debug!("Debug calculation: {i} * 10 = {value}");
41 info!("Processing item #{i} with value {value}");
42 }
43
44 info!("Example completed");
45}