File tree 1 file changed +10
-23
lines changed
1 file changed +10
-23
lines changed Original file line number Diff line number Diff line change 1
- use std:: io:: Write ;
2
-
3
1
fn main ( ) {
4
- match std:: env:: var ( "RUST_LOG_STYLE" ) {
5
- Ok ( s) if s == "SYSTEMD" => env_logger:: builder ( )
6
- . build_with_format_fn ( |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
- . try_init ( )
22
- . unwrap ( ) ,
23
- _ => env_logger:: init ( ) ,
24
- } ;
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" ) ;
25
12
}
You can’t perform that action at this time.
0 commit comments