attach to console on windows if availbalbe

This commit is contained in:
bgkillas 2025-06-19 16:50:29 -04:00
parent b5bafc6bfd
commit 812f3cc7de
3 changed files with 11 additions and 0 deletions

View file

@ -2903,6 +2903,7 @@ dependencies = [
"tracing-subscriber",
"unic-langid",
"wide",
"winapi",
"winresource",
"zip",
]

View file

@ -56,6 +56,9 @@ rubato = "0.16.1"
directories = "6.0.0"
#fundsp = {version = "0.20.0", default-features = false, features = ["std"]}
[target.'cfg(windows)'.dependencies]
winapi="0.3.9"
[dev-dependencies]
serial_test = "3.2.0"

View file

@ -18,6 +18,13 @@ use tracing_subscriber::EnvFilter;
#[allow(clippy::needless_return)]
#[tokio::main(worker_threads = 2)]
async fn main() {
#[cfg(target_os = "windows")]
{
use winapi::um::wincon::{ATTACH_PARENT_PROCESS, AttachConsole};
unsafe {
AttachConsole(ATTACH_PARENT_PROCESS);
}
}
let log = if let Ok(path) = std::env::current_exe() {
path.parent().unwrap().join("ew_log.txt")
} else {