diff --git a/Cargo.lock b/Cargo.lock index 34fa66b6e..d8a994999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3596,6 +3596,7 @@ name = "voicevox_core_c_api" version = "0.0.0" dependencies = [ "anyhow", + "chrono", "is-terminal", "libc", "once_cell", diff --git a/crates/voicevox_core_c_api/Cargo.toml b/crates/voicevox_core_c_api/Cargo.toml index 695243267..43343db92 100644 --- a/crates/voicevox_core_c_api/Cargo.toml +++ b/crates/voicevox_core_c_api/Cargo.toml @@ -13,6 +13,7 @@ directml = ["voicevox_core/directml"] [dependencies] voicevox_core.workspace = true +chrono = { version = "0.4.23", default-features = false, features = ["clock"] } # https://github.com/chronotope/chrono/issues/602 is-terminal = "0.4.2" libc = "0.2.134" once_cell.workspace = true diff --git a/crates/voicevox_core_c_api/src/lib.rs b/crates/voicevox_core_c_api/src/lib.rs index 195f510ba..c09050a71 100644 --- a/crates/voicevox_core_c_api/src/lib.rs +++ b/crates/voicevox_core_c_api/src/lib.rs @@ -7,10 +7,12 @@ use libc::c_void; use once_cell::sync::Lazy; use std::env; use std::ffi::{CStr, CString}; +use std::fmt; use std::io::{self, Write}; use std::os::raw::c_char; use std::ptr::null; use std::sync::{Mutex, MutexGuard}; +use tracing_subscriber::fmt::format::Writer; use tracing_subscriber::EnvFilter; use voicevox_core::AudioQueryModel; use voicevox_core::Result; @@ -32,11 +34,16 @@ static INTERNAL: Lazy> = Lazy::new(|| { } else { "error,voicevox_core=info,voicevox_core_c_api=info,onnxruntime=info".into() }) + .with_timer(local_time as fn(&mut Writer<'_>) -> _) .with_ansi(out().is_terminal() && env_allows_ansi()) .with_writer(out) .try_init() } + fn local_time(wtr: &mut Writer<'_>) -> fmt::Result { + wtr.write_str(&chrono::Local::now().to_rfc3339()) + } + fn out() -> impl IsTerminal + Write { io::stderr() }