mirror of
https://github.com/ankitects/anki.git
synced 2025-12-11 13:56:55 -05:00
skip terminal logging unless LOGTERM defined
seems to be quite slow on Windows
This commit is contained in:
parent
c950a00610
commit
c29184d874
1 changed files with 20 additions and 13 deletions
|
|
@ -29,19 +29,26 @@ fn file(path: &str) -> io::Result<Logger> {
|
|||
let drain = slog_term::FullFormat::new(decorator).build().fuse();
|
||||
let drain = slog_envlogger::new(drain);
|
||||
|
||||
if std::env::var("LOGTERM").is_ok() {
|
||||
// log to the terminal as well
|
||||
let decorator = slog_term::TermDecorator::new().build();
|
||||
let term_drain = slog_term::FullFormat::new(decorator).build().fuse();
|
||||
let term_drain = slog_envlogger::new(term_drain);
|
||||
|
||||
let joined_drain = slog::Duplicate::new(drain, term_drain).fuse();
|
||||
|
||||
let drain = slog_async::Async::new(joined_drain)
|
||||
.chan_size(1_024)
|
||||
.overflow_strategy(OverflowStrategy::Block)
|
||||
.build()
|
||||
.fuse();
|
||||
Ok(Logger::root(drain, slog_o!()))
|
||||
} else {
|
||||
let drain = slog_async::Async::new(drain)
|
||||
.chan_size(1_024)
|
||||
.overflow_strategy(OverflowStrategy::Block)
|
||||
.build()
|
||||
.fuse();
|
||||
Ok(Logger::root(drain, slog_o!()))
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_rotate_log(path: &str) -> io::Result<()> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue