File tree Expand file tree Collapse file tree 1 file changed +10
-22
lines changed Expand file tree Collapse file tree 1 file changed +10
-22
lines changed Original file line number Diff line number Diff line change 1- use std:: io:: Write ;
2-
31fn main ( ) {
4- match std:: env:: var ( "RUST_LOG_STYLE" ) {
5- Ok ( s) if s == "SYSTEMD" => env_logger:: builder ( )
6- . format ( |buf, record| {
7- writeln ! (
8- buf,
9- "<{}>{}: {}" ,
10- match record. level( ) {
11- log:: Level :: Error => 3 ,
12- log:: Level :: Warn => 4 ,
13- log:: Level :: Info => 6 ,
14- log:: Level :: Debug => 7 ,
15- log:: Level :: Trace => 7 ,
16- } ,
17- record. target( ) ,
18- record. args( )
19- )
20- } )
21- . init ( ) ,
22- _ => env_logger:: init ( ) ,
23- } ;
2+ env_logger:: builder ( )
3+ . parse_default_env ( )
4+ // While journald-logging is auto-detected, but you can manually override it.
5+ // Especially useful if you are using a different logging system.
6+ . format_syslog ( true )
7+ . init ( ) ;
8+
9+ // Prints in a human readable way if run interactively,
10+ // and in a syslog-compatible way if run as a systemd service.
11+ log:: info!( "we are logging" ) ;
2412}
You can’t perform that action at this time.
0 commit comments