Skip to content

Commit

Permalink
Disable terminal logging on Windows
Browse files Browse the repository at this point in the history
Work around rust-lang/rust#88576
until the fix lands in stable.
  • Loading branch information
YaLTeR committed Nov 13, 2021
1 parent 0b4a4ed commit 8f8e78b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Once;

use git_version::git_version;
use log::logger;
use simplelog::{CombinedLogger, LevelFilter, SharedLogger, TermLogger, WriteLogger};
use simplelog::{CombinedLogger, LevelFilter, SharedLogger, WriteLogger};

pub mod marker;
pub use marker::*;
Expand Down Expand Up @@ -64,12 +64,20 @@ fn setup_logging_hooks() {
.set_time_format_str("%F %T%.3f")
.set_time_to_local(true)
.build();
let mut logger: Vec<Box<(dyn SharedLogger + 'static)>> = vec![TermLogger::new(

// https://github.com/rust-lang/rust/issues/88576
// In Rust 1.56 terminal logging on Windows causes panics. Disable it until the fix lands in
// stable.
#[cfg(windows)]
let mut logger: Vec<Box<(dyn SharedLogger + 'static)>> = vec![];
#[cfg(not(windows))]
let mut logger: Vec<Box<(dyn SharedLogger + 'static)>> = vec![simplelog::TermLogger::new(
LevelFilter::Trace,
config.clone(),
simplelog::TerminalMode::Stderr,
simplelog::ColorChoice::Auto,
)];

if let Ok(log_file) = OpenOptions::new()
.append(true)
.create(true)
Expand Down

0 comments on commit 8f8e78b

Please sign in to comment.