mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Disable console and write logs to a file instead on Windows.
This commit is contained in:
parent
628572af84
commit
8a8a690cfa
3 changed files with 52 additions and 1 deletions
25
noita-proxy/Cargo.lock
generated
25
noita-proxy/Cargo.lock
generated
|
@ -2077,6 +2077,7 @@ dependencies = [
|
|||
"thiserror 2.0.2",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
"tungstenite",
|
||||
"unic-langid",
|
||||
|
@ -3518,10 +3519,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"num-conv",
|
||||
"powerfmt",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3530,6 +3533,16 @@ version = "0.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiny-skia"
|
||||
version = "0.11.4"
|
||||
|
@ -3695,6 +3708,18 @@ dependencies = [
|
|||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-appender"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"thiserror 1.0.69",
|
||||
"time",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.27"
|
||||
|
|
|
@ -49,6 +49,7 @@ quick-xml = { version = "0.37.0", features = ["serialize"] }
|
|||
dashmap = "6.0.1"
|
||||
eyre = "0.6.12"
|
||||
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
|
||||
tracing-appender = "0.2.3"
|
||||
|
||||
[build-dependencies]
|
||||
winresource = "0.1.17"
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
#![windows_subsystem = "windows"]
|
||||
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, BufWriter},
|
||||
};
|
||||
|
||||
use eframe::{
|
||||
egui::{IconData, ViewportBuilder},
|
||||
NativeOptions,
|
||||
|
@ -9,13 +16,31 @@ use tracing_subscriber::EnvFilter;
|
|||
#[allow(clippy::needless_return)]
|
||||
#[tokio::main(worker_threads = 2)]
|
||||
async fn main() {
|
||||
let log_to_file = cfg!(windows);
|
||||
let writer = {
|
||||
if log_to_file {
|
||||
let file = File::create("ew_log.txt");
|
||||
println!("Creating a log file");
|
||||
match file {
|
||||
Ok(file) => Box::new(BufWriter::new(file)) as Box<dyn io::Write + Send>,
|
||||
Err(_) => Box::new(std::io::stdout()) as Box<dyn io::Write + Send>,
|
||||
}
|
||||
} else {
|
||||
Box::new(std::io::stdout()) as Box<dyn io::Write + Send>
|
||||
}
|
||||
};
|
||||
|
||||
let (non_blocking_writer, _guard) = tracing_appender::non_blocking(writer);
|
||||
|
||||
let my_subscriber = tracing_subscriber::FmtSubscriber::builder()
|
||||
.with_env_filter(
|
||||
EnvFilter::builder()
|
||||
.with_default_directive(LevelFilter::INFO.into())
|
||||
.from_env_lossy(),
|
||||
)
|
||||
.with_writer(non_blocking_writer)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::set_global_default(my_subscriber).expect("setting tracing default failed");
|
||||
|
||||
let args: Args = argh::from_env();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue