tracing: removed env-filter and use of RUST_LOG

it increased build size by 1 MB
This commit is contained in:
Observer KRypt0n_ 2023-02-23 14:29:57 +02:00
parent 1dcc1b5403
commit efa96b9d2b
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 14 additions and 36 deletions

22
Cargo.lock generated
View file

@ -1271,15 +1271,6 @@ 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"
@ -1660,15 +1651,6 @@ 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"
@ -2184,14 +2166,10 @@ 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",
] ]

View file

@ -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 = { version = "0.3", features = ["env-filter"] } tracing-subscriber = "0.3"
fluent-templates = "0.8" fluent-templates = "0.8"
unic-langid = "0.9" unic-langid = "0.9"

View file

@ -44,21 +44,19 @@ fn main() {
// Force debug output // Force debug output
let force_debug = std::env::args().any(|arg| &arg == "--debug"); 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 // Prepare stdout logger
let stdout = tracing_subscriber::fmt::layer() let stdout = tracing_subscriber::fmt::layer()
.pretty() .pretty()
.with_filter(EnvFilter::from_default_env()); .with_filter({
if APP_DEBUG || force_debug {
LevelFilter::TRACE
} else {
LevelFilter::WARN
}
})
.with_filter(filter_fn(|metadata| {
!metadata.target().contains("rustls")
}));
// Prepare debug file logger // 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()) {
@ -69,7 +67,9 @@ fn main() {
let 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) .with_ansi(false)
.with_filter(EnvFilter::from_default_env()); .with_filter(filter_fn(|metadata| {
!metadata.target().contains("rustls")
}));
tracing_subscriber::registry() tracing_subscriber::registry()
.with(stdout) .with(stdout)