tracing: improved logs output
- now launcher can use `RUST_LOG` variable to filter logs - removed "called event" logs from wine/dxvk/progress bar components Also: - fixed constant "remove_css_class" gtk errors
This commit is contained in:
parent
4e6325dd4f
commit
1dcc1b5403
9 changed files with 71 additions and 56 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -46,6 +46,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"tar",
|
"tar",
|
||||||
|
"tracing",
|
||||||
"xz",
|
"xz",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
@ -79,6 +80,7 @@ dependencies = [
|
||||||
"md5",
|
"md5",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tracing",
|
||||||
"wincompatlib",
|
"wincompatlib",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1269,6 +1271,15 @@ dependencies = [
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matchers"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||||
|
dependencies = [
|
||||||
|
"regex-automata",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "md5"
|
name = "md5"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
@ -1649,6 +1660,15 @@ dependencies = [
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||||
|
dependencies = [
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.6.28"
|
version = "0.6.28"
|
||||||
|
@ -1979,9 +1999,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysinfo"
|
name = "sysinfo"
|
||||||
version = "0.27.1"
|
version = "0.28.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ccb297c0afb439440834b4bcf02c5c9da8ec2e808e70f36b0d8e815ff403bd24"
|
checksum = "727220a596b4ca0af040a07091e49f5c105ec8f2592674339a5bf35be592f76e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
|
@ -2164,10 +2184,14 @@ version = "0.3.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
|
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"matchers",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
|
"once_cell",
|
||||||
|
"regex",
|
||||||
"sharded-slab",
|
"sharded-slab",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
|
"tracing",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
]
|
]
|
||||||
|
|
|
@ -23,7 +23,7 @@ adw = { package = "libadwaita", version = "0.2", features = ["v1_2"] }
|
||||||
anime-launcher-sdk = { path = "anime-launcher-sdk" }
|
anime-launcher-sdk = { path = "anime-launcher-sdk" }
|
||||||
|
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
fluent-templates = "0.8"
|
fluent-templates = "0.8"
|
||||||
unic-langid = "0.9"
|
unic-langid = "0.9"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a62aeef9cd9caa0e147fddcf05f4c412c942b736
|
Subproject commit 2e726358a2a74af9f35a5c55ea3bc6e7025575ae
|
45
src/main.rs
45
src/main.rs
|
@ -5,6 +5,7 @@ use anime_launcher_sdk::anime_game_core::prelude::*;
|
||||||
use anime_launcher_sdk::anime_game_core::genshin::prelude::*;
|
use anime_launcher_sdk::anime_game_core::genshin::prelude::*;
|
||||||
|
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::prelude::*;
|
||||||
|
use tracing_subscriber::filter::*;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -40,33 +41,39 @@ lazy_static::lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let stdout = tracing_subscriber::fmt::layer().pretty();
|
// Force debug output
|
||||||
|
let force_debug = std::env::args().any(|arg| &arg == "--debug");
|
||||||
|
|
||||||
|
// Update RUST_LOG env variable if needed
|
||||||
|
if !std::env::vars().any(|(key, _)| key == "RUST_LOG") {
|
||||||
|
std::env::set_var("RUST_LOG", {
|
||||||
|
if APP_DEBUG || force_debug {
|
||||||
|
"trace"
|
||||||
|
} else {
|
||||||
|
"warn"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare stdout logger
|
||||||
|
let stdout = tracing_subscriber::fmt::layer()
|
||||||
|
.pretty()
|
||||||
|
.with_filter(EnvFilter::from_default_env());
|
||||||
|
|
||||||
|
// Prepare debug file logger
|
||||||
let file = match std::fs::File::create(DEBUG_FILE.as_path()) {
|
let file = match std::fs::File::create(DEBUG_FILE.as_path()) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(error) => panic!("Failed to create debug.log file: {:?}", error)
|
Err(error) => panic!("Failed to create debug.log file: {:?}", error)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut debug_log = tracing_subscriber::fmt::layer()
|
let debug_log = tracing_subscriber::fmt::layer()
|
||||||
.with_writer(std::sync::Arc::new(file));
|
.with_writer(std::sync::Arc::new(file))
|
||||||
|
.with_ansi(false)
|
||||||
debug_log.set_ansi(false);
|
.with_filter(EnvFilter::from_default_env());
|
||||||
|
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with({
|
.with(stdout)
|
||||||
stdout
|
.with(debug_log)
|
||||||
.with_filter(tracing_subscriber::filter::LevelFilter::from_level({
|
|
||||||
if APP_DEBUG || std::env::args().any(|arg| &arg == "--debug") {
|
|
||||||
tracing::Level::TRACE
|
|
||||||
} else {
|
|
||||||
tracing::Level::WARN
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.with_filter(tracing_subscriber::filter::filter_fn(|metadata| {
|
|
||||||
!metadata.target().starts_with("rustls")
|
|
||||||
}))
|
|
||||||
.and_then(debug_log)
|
|
||||||
})
|
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
tracing::info!("Starting application");
|
tracing::info!("Starting application");
|
||||||
|
|
|
@ -61,8 +61,6 @@ impl SimpleAsyncComponent for ComponentGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||||
tracing::debug!("Called component group [{}] event: {:?}", self.title, msg);
|
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
AppMsg::ShowRecommendedOnly(state) => {
|
AppMsg::ShowRecommendedOnly(state) => {
|
||||||
self.show_recommended_only = state;
|
self.show_recommended_only = state;
|
||||||
|
|
|
@ -66,8 +66,6 @@ impl<T: std::fmt::Debug + Clone + 'static> SimpleAsyncComponent for ComponentsLi
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||||
tracing::debug!("Called components list event: {:?}", msg);
|
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
AppMsg::ShowRecommendedOnly(state) => {
|
AppMsg::ShowRecommendedOnly(state) => {
|
||||||
self.show_recommended_only = state;
|
self.show_recommended_only = state;
|
||||||
|
|
|
@ -110,8 +110,6 @@ impl SimpleAsyncComponent for ProgressBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(&mut self, msg: Self::Input, _sender: AsyncComponentSender<Self>) {
|
async fn update(&mut self, msg: Self::Input, _sender: AsyncComponentSender<Self>) {
|
||||||
tracing::debug!("Called components list event: {:?}", msg);
|
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
AppMsg::Reset => {
|
AppMsg::Reset => {
|
||||||
self.fraction = 0.0;
|
self.fraction = 0.0;
|
||||||
|
|
|
@ -119,8 +119,6 @@ impl SimpleAsyncComponent for ComponentVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||||
tracing::debug!("Called component version [{}] event: {:?} (state = {:?})", self.title, msg, self.state);
|
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
AppMsg::ShowRecommendedOnly(state) => self.show_recommended_only = state,
|
AppMsg::ShowRecommendedOnly(state) => self.show_recommended_only = state,
|
||||||
|
|
||||||
|
|
|
@ -103,21 +103,23 @@ impl SimpleComponent for App {
|
||||||
),
|
),
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
add_css_class: match model.style {
|
set_css_classes: &{
|
||||||
LauncherStyle::Modern => "",
|
let mut classes = vec!["background", "csd"];
|
||||||
|
|
||||||
|
if APP_DEBUG {
|
||||||
|
classes.push("devel");
|
||||||
|
}
|
||||||
|
|
||||||
|
match model.style {
|
||||||
|
LauncherStyle::Modern => (),
|
||||||
LauncherStyle::Classic => {
|
LauncherStyle::Classic => {
|
||||||
if model.loading.is_none() {
|
if model.loading.is_none() {
|
||||||
"classic-style"
|
classes.push("classic-style");
|
||||||
} else {
|
}
|
||||||
""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
#[watch]
|
classes
|
||||||
remove_css_class: match model.style {
|
|
||||||
LauncherStyle::Modern => "classic-style",
|
|
||||||
LauncherStyle::Classic => ""
|
|
||||||
},
|
},
|
||||||
|
|
||||||
#[local_ref]
|
#[local_ref]
|
||||||
|
@ -127,15 +129,9 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
adw::HeaderBar {
|
adw::HeaderBar {
|
||||||
#[watch]
|
#[watch]
|
||||||
add_css_class: match model.style {
|
set_css_classes: match model.style {
|
||||||
LauncherStyle::Modern => "",
|
LauncherStyle::Modern => &[""],
|
||||||
LauncherStyle::Classic => "flat"
|
LauncherStyle::Classic => &["flat"]
|
||||||
},
|
|
||||||
|
|
||||||
#[watch]
|
|
||||||
remove_css_class: match model.style {
|
|
||||||
LauncherStyle::Modern => "flat",
|
|
||||||
LauncherStyle::Classic => ""
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pack_end = >k::MenuButton {
|
pack_end = >k::MenuButton {
|
||||||
|
@ -330,10 +326,6 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
|
||||||
if crate::APP_DEBUG {
|
|
||||||
widgets.main_window.add_css_class("devel");
|
|
||||||
}
|
|
||||||
|
|
||||||
let about_dialog_broker: MessageBroker<AboutDialog> = MessageBroker::new();
|
let about_dialog_broker: MessageBroker<AboutDialog> = MessageBroker::new();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Reference in a new issue