Skip to content

Commit

Permalink
Fixes for tracing on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed Nov 12, 2023
1 parent f3bc5c1 commit ee3b110
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions td-rs-base/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#![feature(associated_type_defaults)]
#![feature(min_specialization)]
#![feature(lazy_cell)]

use std::cell::OnceCell;
use std::collections::HashMap;
use std::ffi;
use std::fmt::Formatter;
use std::ops::Index;
use std::pin::Pin;
use std::sync::{LazyLock, Mutex};

pub use param::*;
#[cfg(feature = "python")]
pub use py::*;

pub static HASHMAP: LazyLock<Mutex<HashMap<String, i32>>> = LazyLock::new(|| Mutex::new(HashMap::new()));

pub mod chop;
pub mod cxx;
pub mod dat;
Expand Down Expand Up @@ -561,12 +566,30 @@ pub fn op_init() {
{
use tracing_subscriber::fmt;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::EnvFilter;

tracing_subscriber::registry()
.with(fmt::layer())
use tracing_subscriber::util::{SubscriberInitExt, TryInitError};

let fmt_layer = if cfg!(target_os = "windows") {
let mut f = fmt::layer();
f.set_ansi(false);
f
} else {
fmt::layer()
};
let init = tracing_subscriber::registry()
.with(fmt_layer)
.with(EnvFilter::from_default_env())
.init();
.try_init();
match init {
Ok(_) => {}
Err(err) => {
match err {
TryInitError { .. } => {}
_ => {

Check warning on line 588 in td-rs-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

unreachable pattern
eprintln!("Failed to initialize tracing: {}", err);
}
}
}
}
}
}

0 comments on commit ee3b110

Please sign in to comment.