mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
feat: bump version of env_logger and modify code for it
Use default style of env_logger instead of custom style.
This commit is contained in:
parent
7b60a88176
commit
4db5163959
3 changed files with 83 additions and 54 deletions
87
Cargo.lock
generated
87
Cargo.lock
generated
|
@ -166,6 +166,54 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.80"
|
||||
|
@ -882,6 +930,12 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.6"
|
||||
|
@ -1634,6 +1688,16 @@ dependencies = [
|
|||
"syn 2.0.51",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.5.13"
|
||||
|
@ -1649,15 +1713,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.10.2"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
|
||||
checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"env_filter",
|
||||
"humantime 2.1.0",
|
||||
"is-terminal",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2199,7 +2263,7 @@ dependencies = [
|
|||
"eframe",
|
||||
"egui",
|
||||
"egui_extras",
|
||||
"env_logger 0.10.2",
|
||||
"env_logger 0.11.2",
|
||||
"figment",
|
||||
"flate2",
|
||||
"hyper",
|
||||
|
@ -2551,17 +2615,6 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.3",
|
||||
"rustix",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_elevated"
|
||||
version = "0.1.2"
|
||||
|
|
|
@ -52,7 +52,7 @@ eframe = { version = "0.24.1", default-features = false, features = ["glow"] }
|
|||
#egui_glow = { path = "external/egui/crates/egui_glow"}
|
||||
#egui_extras = { path = "external/egui/crates/egui_extras", features = ["image"] }
|
||||
#--------------------------------------------------------------------------------
|
||||
env_logger = "0.10.2"
|
||||
env_logger = "0.11.2"
|
||||
figment = { version = "0.10.14", features = ["toml"] }
|
||||
hyper = "0.14.28"
|
||||
hyper-tls = "0.5.0"
|
||||
|
|
48
src/main.rs
48
src/main.rs
|
@ -35,7 +35,10 @@ use egui::{
|
|||
};
|
||||
use egui_extras::RetainedImage;
|
||||
// Logging
|
||||
use env_logger::{Builder, WriteStyle};
|
||||
use env_logger::{
|
||||
fmt::style::{AnsiColor, Style},
|
||||
Builder, WriteStyle,
|
||||
};
|
||||
use log::*;
|
||||
// Regex
|
||||
use ::regex::Regex;
|
||||
|
@ -931,7 +934,6 @@ fn init_text_styles(ctx: &egui::Context, width: f32, pixels_per_point: f32) {
|
|||
#[cold]
|
||||
#[inline(never)]
|
||||
fn init_logger(now: Instant) {
|
||||
use env_logger::fmt::Color;
|
||||
let filter_env = std::env::var("RUST_LOG").unwrap_or_else(|_| "INFO".to_string());
|
||||
let filter = match filter_env.as_str() {
|
||||
"error" | "Error" | "ERROR" => LevelFilter::Error,
|
||||
|
@ -944,42 +946,16 @@ fn init_logger(now: Instant) {
|
|||
|
||||
Builder::new()
|
||||
.format(move |buf, record| {
|
||||
let mut style = buf.style();
|
||||
let level = match record.level() {
|
||||
Level::Error => {
|
||||
style.set_color(Color::Red);
|
||||
"ERROR"
|
||||
}
|
||||
Level::Warn => {
|
||||
style.set_color(Color::Yellow);
|
||||
"WARN"
|
||||
}
|
||||
Level::Info => {
|
||||
style.set_color(Color::White);
|
||||
"INFO"
|
||||
}
|
||||
Level::Debug => {
|
||||
style.set_color(Color::Blue);
|
||||
"DEBUG"
|
||||
}
|
||||
Level::Trace => {
|
||||
style.set_color(Color::Magenta);
|
||||
"TRACE"
|
||||
}
|
||||
};
|
||||
let level = record.level();
|
||||
let level_style = buf.default_level_style(level);
|
||||
let dimmed = Style::new().dimmed();
|
||||
writeln!(
|
||||
buf,
|
||||
"[{}] [{}] [{}:{}] {}",
|
||||
style.set_bold(true).value(level),
|
||||
buf.style()
|
||||
.set_dimmed(true)
|
||||
.value(format!("{:.3}", now.elapsed().as_secs_f32())),
|
||||
buf.style()
|
||||
.set_dimmed(true)
|
||||
.value(record.file().unwrap_or("???")),
|
||||
buf.style()
|
||||
.set_dimmed(true)
|
||||
.value(record.line().unwrap_or(0)),
|
||||
"{level_style}[{}]{level_style:#} [{dimmed}{}{dimmed:#}] [{dimmed}{}{dimmed:#}:{dimmed}{}{dimmed:#}] {}",
|
||||
level,
|
||||
format!("{:.3}", now.elapsed().as_secs_f32()),
|
||||
record.file().unwrap_or("???"),
|
||||
record.line().unwrap_or(0),
|
||||
record.args(),
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue