pub fn set_target(t: Target)Expand description
Sets the output target once. Subsequent calls are ignored.
Call this early (e.g., at program start) if you need Stdout or a custom Writer.
Examples found in repository?
examples/basic.rs (line 12)
8fn main() {
9 // Initialize from environment (optional):
10 // RUST_LOG_LEVEL=debug RUST_LOG_COLOR=always RUST_LOG_SHOW_TID=1 RUST_LOG_SHOW_TIME=1
11 set_level(Level::Trace); // runtime threshold
12 set_target(Target::Stderr); // default
13 set_show_file_line(true);
14 set_show_thread_id(true);
15 set_show_time(true);
16 init_from_env();
17
18 banner!();
19
20 trace!("hello {}", "world");
21 debug!("hello {}", "world");
22 info!("hello {}", "world");
23 warn!("disk almost full: {}%", 92);
24 error!("disk almost full: {}%", 92);
25 fatal!("disk almost full: {}%", 92);
26
27 scope_time!("startup", {
28 debug!("only visible at DEBUG+");
29 std::thread::sleep(std::time::Duration::from_millis(10));
30 });
31
32 info_group!("net", "retry in {} ms", 200);
33}