This repository was archived by the owner on Nov 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
client/tracing/src/logging Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ pub struct EventFormat<T = SystemTime> {
43
43
pub display_thread_name : bool ,
44
44
/// Enable ANSI terminal colors for formatted output.
45
45
pub enable_color : bool ,
46
+ /// Duplicate INFO, WARN and ERROR messages to stdout.
47
+ pub dup_to_stdout : bool ,
46
48
}
47
49
48
50
impl < T > EventFormat < T >
@@ -123,7 +125,19 @@ where
123
125
writer : & mut dyn fmt:: Write ,
124
126
event : & Event ,
125
127
) -> fmt:: Result {
126
- self . format_event_custom ( CustomFmtContext :: FmtContext ( ctx) , writer, event)
128
+ if self . dup_to_stdout && (
129
+ event. metadata ( ) . level ( ) == & Level :: INFO ||
130
+ event. metadata ( ) . level ( ) == & Level :: WARN ||
131
+ event. metadata ( ) . level ( ) == & Level :: ERROR
132
+ ) {
133
+ let mut out = String :: new ( ) ;
134
+ self . format_event_custom ( CustomFmtContext :: FmtContext ( ctx) , & mut out, event) ?;
135
+ writer. write_str ( & out) ?;
136
+ print ! ( "{}" , out) ;
137
+ Ok ( ( ) )
138
+ } else {
139
+ self . format_event_custom ( CustomFmtContext :: FmtContext ( ctx) , writer, event)
140
+ }
127
141
}
128
142
}
129
143
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ where
167
167
display_level : !simple,
168
168
display_thread_name : !simple,
169
169
enable_color,
170
+ dup_to_stdout : !atty:: is ( atty:: Stream :: Stderr ) && atty:: is ( atty:: Stream :: Stdout ) ,
170
171
} ;
171
172
let builder = FmtSubscriber :: builder ( ) . with_env_filter ( env_filter) ;
172
173
You can’t perform that action at this time.
0 commit comments