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",
|
"thiserror 2.0.2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-appender",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"tungstenite",
|
"tungstenite",
|
||||||
"unic-langid",
|
"unic-langid",
|
||||||
|
@ -3518,10 +3519,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
|
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
|
"itoa",
|
||||||
"num-conv",
|
"num-conv",
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
"serde",
|
"serde",
|
||||||
"time-core",
|
"time-core",
|
||||||
|
"time-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3530,6 +3533,16 @@ version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
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]]
|
[[package]]
|
||||||
name = "tiny-skia"
|
name = "tiny-skia"
|
||||||
version = "0.11.4"
|
version = "0.11.4"
|
||||||
|
@ -3695,6 +3708,18 @@ dependencies = [
|
||||||
"tracing-core",
|
"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]]
|
[[package]]
|
||||||
name = "tracing-attributes"
|
name = "tracing-attributes"
|
||||||
version = "0.1.27"
|
version = "0.1.27"
|
||||||
|
|
|
@ -49,6 +49,7 @@ quick-xml = { version = "0.37.0", features = ["serialize"] }
|
||||||
dashmap = "6.0.1"
|
dashmap = "6.0.1"
|
||||||
eyre = "0.6.12"
|
eyre = "0.6.12"
|
||||||
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
tracing-appender = "0.2.3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
winresource = "0.1.17"
|
winresource = "0.1.17"
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::{self, BufWriter},
|
||||||
|
};
|
||||||
|
|
||||||
use eframe::{
|
use eframe::{
|
||||||
egui::{IconData, ViewportBuilder},
|
egui::{IconData, ViewportBuilder},
|
||||||
NativeOptions,
|
NativeOptions,
|
||||||
|
@ -9,13 +16,31 @@ use tracing_subscriber::EnvFilter;
|
||||||
#[allow(clippy::needless_return)]
|
#[allow(clippy::needless_return)]
|
||||||
#[tokio::main(worker_threads = 2)]
|
#[tokio::main(worker_threads = 2)]
|
||||||
async fn main() {
|
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()
|
let my_subscriber = tracing_subscriber::FmtSubscriber::builder()
|
||||||
.with_env_filter(
|
.with_env_filter(
|
||||||
EnvFilter::builder()
|
EnvFilter::builder()
|
||||||
.with_default_directive(LevelFilter::INFO.into())
|
.with_default_directive(LevelFilter::INFO.into())
|
||||||
.from_env_lossy(),
|
.from_env_lossy(),
|
||||||
)
|
)
|
||||||
|
.with_writer(non_blocking_writer)
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
tracing::subscriber::set_global_default(my_subscriber).expect("setting tracing default failed");
|
tracing::subscriber::set_global_default(my_subscriber).expect("setting tracing default failed");
|
||||||
|
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue