mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 22:59:27 +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",
|
"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]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.80"
|
version = "1.0.80"
|
||||||
|
@ -882,6 +930,12 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorchoice"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "combine"
|
name = "combine"
|
||||||
version = "4.6.6"
|
version = "4.6.6"
|
||||||
|
@ -1634,6 +1688,16 @@ dependencies = [
|
||||||
"syn 2.0.51",
|
"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]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.5.13"
|
version = "0.5.13"
|
||||||
|
@ -1649,15 +1713,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.10.2"
|
version = "0.11.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
|
checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anstream",
|
||||||
|
"anstyle",
|
||||||
|
"env_filter",
|
||||||
"humantime 2.1.0",
|
"humantime 2.1.0",
|
||||||
"is-terminal",
|
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
|
||||||
"termcolor",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2199,7 +2263,7 @@ dependencies = [
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
"env_logger 0.10.2",
|
"env_logger 0.11.2",
|
||||||
"figment",
|
"figment",
|
||||||
"flate2",
|
"flate2",
|
||||||
"hyper",
|
"hyper",
|
||||||
|
@ -2551,17 +2615,6 @@ dependencies = [
|
||||||
"libc",
|
"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]]
|
[[package]]
|
||||||
name = "is_elevated"
|
name = "is_elevated"
|
||||||
version = "0.1.2"
|
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_glow = { path = "external/egui/crates/egui_glow"}
|
||||||
#egui_extras = { path = "external/egui/crates/egui_extras", features = ["image"] }
|
#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"] }
|
figment = { version = "0.10.14", features = ["toml"] }
|
||||||
hyper = "0.14.28"
|
hyper = "0.14.28"
|
||||||
hyper-tls = "0.5.0"
|
hyper-tls = "0.5.0"
|
||||||
|
|
48
src/main.rs
48
src/main.rs
|
@ -35,7 +35,10 @@ use egui::{
|
||||||
};
|
};
|
||||||
use egui_extras::RetainedImage;
|
use egui_extras::RetainedImage;
|
||||||
// Logging
|
// Logging
|
||||||
use env_logger::{Builder, WriteStyle};
|
use env_logger::{
|
||||||
|
fmt::style::{AnsiColor, Style},
|
||||||
|
Builder, WriteStyle,
|
||||||
|
};
|
||||||
use log::*;
|
use log::*;
|
||||||
// Regex
|
// Regex
|
||||||
use ::regex::Regex;
|
use ::regex::Regex;
|
||||||
|
@ -931,7 +934,6 @@ fn init_text_styles(ctx: &egui::Context, width: f32, pixels_per_point: f32) {
|
||||||
#[cold]
|
#[cold]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn init_logger(now: Instant) {
|
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_env = std::env::var("RUST_LOG").unwrap_or_else(|_| "INFO".to_string());
|
||||||
let filter = match filter_env.as_str() {
|
let filter = match filter_env.as_str() {
|
||||||
"error" | "Error" | "ERROR" => LevelFilter::Error,
|
"error" | "Error" | "ERROR" => LevelFilter::Error,
|
||||||
|
@ -944,42 +946,16 @@ fn init_logger(now: Instant) {
|
||||||
|
|
||||||
Builder::new()
|
Builder::new()
|
||||||
.format(move |buf, record| {
|
.format(move |buf, record| {
|
||||||
let mut style = buf.style();
|
let level = record.level();
|
||||||
let level = match record.level() {
|
let level_style = buf.default_level_style(level);
|
||||||
Level::Error => {
|
let dimmed = Style::new().dimmed();
|
||||||
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"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
writeln!(
|
writeln!(
|
||||||
buf,
|
buf,
|
||||||
"[{}] [{}] [{}:{}] {}",
|
"{level_style}[{}]{level_style:#} [{dimmed}{}{dimmed:#}] [{dimmed}{}{dimmed:#}:{dimmed}{}{dimmed:#}] {}",
|
||||||
style.set_bold(true).value(level),
|
level,
|
||||||
buf.style()
|
format!("{:.3}", now.elapsed().as_secs_f32()),
|
||||||
.set_dimmed(true)
|
record.file().unwrap_or("???"),
|
||||||
.value(format!("{:.3}", now.elapsed().as_secs_f32())),
|
record.line().unwrap_or(0),
|
||||||
buf.style()
|
|
||||||
.set_dimmed(true)
|
|
||||||
.value(record.file().unwrap_or("???")),
|
|
||||||
buf.style()
|
|
||||||
.set_dimmed(true)
|
|
||||||
.value(record.line().unwrap_or(0)),
|
|
||||||
record.args(),
|
record.args(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue