File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ vm-fdt = "0.2.0"
30
30
vm-superio = " 0.7.0"
31
31
tracing = { version = " 0.1.37" , features = [" attributes" ] }
32
32
tracing-subscriber = " 0.3.17"
33
+ tracing-flame = " 0.2.0"
33
34
log = { version = " 0.4.17" , features = [" serde" ] }
34
35
35
36
dumbo = { path = " ../dumbo" }
Original file line number Diff line number Diff line change @@ -190,9 +190,10 @@ pub struct LoggerConfig {
190
190
pub show_level : Option < bool > ,
191
191
/// When enabled, the logger will append the origin of the log entry.
192
192
pub show_log_origin : Option < bool > ,
193
+ /// The profile file to output.
194
+ pub profile_file : Option < std:: path:: PathBuf > ,
193
195
}
194
196
195
-
196
197
impl LoggerConfig {
197
198
/// Initalizes the logger.
198
199
pub fn init ( & self ) {
@@ -226,7 +227,20 @@ impl LoggerConfig {
226
227
227
228
let fmt_layer = fmt_layer. with_writer ( writer. with_max_level ( level) ) ;
228
229
229
- tracing_subscriber:: registry ( ) . with ( fmt_layer) . init ( ) ;
230
+ if let Some ( profile_file) = & self . profile_file {
231
+ // We can discard the flush guard as
232
+ // > This type is only needed when using
233
+ // > `tracing::subscriber::set_global_default`, which prevents the drop
234
+ // > implementation of layers from running when the program exits.
235
+ // See https://docs.rs/tracing-flame/0.2.0/tracing_flame/struct.FlushGuard.html
236
+ let ( flame_layer, _guard) = tracing_flame:: FlameLayer :: with_file ( profile_file) . unwrap ( ) ;
237
+ tracing_subscriber:: registry ( )
238
+ . with ( fmt_layer)
239
+ . with ( flame_layer)
240
+ . init ( ) ;
241
+ } else {
242
+ tracing_subscriber:: registry ( ) . with ( fmt_layer) . init ( ) ;
243
+ }
230
244
}
231
245
}
232
246
You can’t perform that action at this time.
0 commit comments