mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Optimize logging (#992)
`Async<Discard>` means "drain that will send each logging record to an async thread, that will discard it". This means logging record is sent to another thread for no reason.
This commit is contained in:
parent
5bc9e29974
commit
2b2e13be63
1 changed files with 8 additions and 9 deletions
|
@ -64,9 +64,8 @@ lazy_static! {
|
|||
terminal_drain = slog_async::Async::new(Discard{}).build().fuse();
|
||||
}
|
||||
|
||||
//File drain
|
||||
let mut file_drain_final = slog_async::Async::new(Discard{}).build().fuse();
|
||||
if config.log_to_file && was_init {
|
||||
//File drain
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
|
@ -78,14 +77,14 @@ lazy_static! {
|
|||
let file_decorator = slog_term::PlainDecorator::new(file);
|
||||
let file_drain = slog_term::FullFormat::new(file_decorator).build().fuse();
|
||||
let file_drain = LevelFilter::new(file_drain, slog_level_file).fuse();
|
||||
file_drain_final = slog_async::Async::new(file_drain).build().fuse();
|
||||
let file_drain_final = slog_async::Async::new(file_drain).build().fuse();
|
||||
|
||||
let composite_drain = Duplicate::new(terminal_drain, file_drain_final).fuse();
|
||||
|
||||
Logger::root(composite_drain, o!())
|
||||
} else {
|
||||
Logger::root(terminal_drain, o!())
|
||||
}
|
||||
|
||||
//Compose file and terminal drains
|
||||
let composite_drain = Duplicate::new(terminal_drain, file_drain_final).fuse();
|
||||
|
||||
let log = Logger::root(composite_drain, o!());
|
||||
log
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue