generated from PlexSheep/rs-base
refactor(log): remove annoying INFO logs on linux
This commit is contained in:
parent
48d81d57b6
commit
5e4a1cbe5b
|
@ -26,3 +26,4 @@ clap = { version = "4.5.15", features = ["derive"] }
|
||||||
image = "0.25.2"
|
image = "0.25.2"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
rfd = "0.14.1"
|
rfd = "0.14.1"
|
||||||
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
|
|
26
src/app.rs
26
src/app.rs
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use egui::IconData;
|
use egui::IconData;
|
||||||
use libpt::cli::args::{VerbosityLevel, HELP_TEMPLATE};
|
use libpt::cli::args::{VerbosityLevel, HELP_TEMPLATE};
|
||||||
use libpt::log::{debug, trace};
|
use libpt::log::trace;
|
||||||
|
|
||||||
pub const TITLE: &str = "Rollator";
|
pub const TITLE: &str = "Rollator";
|
||||||
|
|
||||||
|
@ -23,8 +23,9 @@ pub struct RollatorApp {
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
pub(crate) verbosity: VerbosityLevel,
|
pub(crate) verbosity: VerbosityLevel,
|
||||||
|
|
||||||
|
/// open the informations window on start
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
#[clap(skip)]
|
#[arg(short = 'i', long = "info")]
|
||||||
show_info_window: bool,
|
show_info_window: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +65,9 @@ impl RollatorApp {
|
||||||
pub fn info_diag(&mut self, ctx: &egui::Context) {
|
pub fn info_diag(&mut self, ctx: &egui::Context) {
|
||||||
trace!("rendering info dialogue");
|
trace!("rendering info dialogue");
|
||||||
ctx.show_viewport_immediate(
|
ctx.show_viewport_immediate(
|
||||||
egui::ViewportId::from_hash_of("immediate_viewport"),
|
egui::ViewportId::from_hash_of(format!("{TITLE}: Information")),
|
||||||
egui::ViewportBuilder::default()
|
egui::ViewportBuilder::default()
|
||||||
.with_title("Immediate Viewport")
|
.with_title(format!("{TITLE}: Information"))
|
||||||
.with_inner_size([500.0, 200.0]),
|
.with_inner_size([500.0, 200.0]),
|
||||||
|ctx, class| {
|
|ctx, class| {
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -75,7 +76,6 @@ impl RollatorApp {
|
||||||
);
|
);
|
||||||
|
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.spacing_mut().item_spacing.x = 0.0;
|
|
||||||
ui.label(format!("{TITLE} v{}", env!("CARGO_PKG_VERSION")));
|
ui.label(format!("{TITLE} v{}", env!("CARGO_PKG_VERSION")));
|
||||||
ui.hyperlink_to("Source Code\n", env!("CARGO_PKG_REPOSITORY"));
|
ui.hyperlink_to("Source Code\n", env!("CARGO_PKG_REPOSITORY"));
|
||||||
ui.label(format!("Author: {}", env!("CARGO_PKG_AUTHORS")));
|
ui.label(format!("Author: {}", env!("CARGO_PKG_AUTHORS")));
|
||||||
|
@ -86,7 +86,17 @@ impl RollatorApp {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bottom_label(ui);
|
ui.horizontal(|ui| {
|
||||||
|
ui.spacing_mut().item_spacing.x = 0.0;
|
||||||
|
ui.label("Powered by ");
|
||||||
|
ui.hyperlink_to("egui", "https://github.com/emilk/egui");
|
||||||
|
ui.label(" and ");
|
||||||
|
ui.hyperlink_to(
|
||||||
|
"eframe",
|
||||||
|
"https://github.com/emilk/egui/tree/master/crates/eframe",
|
||||||
|
);
|
||||||
|
ui.label(".");
|
||||||
|
});
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
});
|
});
|
||||||
|
@ -163,8 +173,8 @@ impl eframe::App for RollatorApp {
|
||||||
fn bottom_label(ui: &mut egui::Ui) {
|
fn bottom_label(ui: &mut egui::Ui) {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.spacing_mut().item_spacing.x = 0.0;
|
ui.spacing_mut().item_spacing.x = 0.0;
|
||||||
ui.hyperlink_to("Source Code ", env!("CARGO_PKG_REPOSITORY"));
|
ui.label(format!("{TITLE} v{}", env!("CARGO_PKG_VERSION")));
|
||||||
ui.label("| Powered by ");
|
ui.label(" | Powered by ");
|
||||||
ui.hyperlink_to("egui", "https://github.com/emilk/egui");
|
ui.hyperlink_to("egui", "https://github.com/emilk/egui");
|
||||||
ui.label(" and ");
|
ui.label(" and ");
|
||||||
ui.hyperlink_to(
|
ui.hyperlink_to(
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -6,12 +6,26 @@ mod app;
|
||||||
// When compiling natively:
|
// When compiling natively:
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
|
use libpt::log::debug;
|
||||||
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
|
|
||||||
let mut app = app::RollatorApp::new_with_cli();
|
let mut app = app::RollatorApp::new_with_cli();
|
||||||
|
|
||||||
let _logger = libpt::log::Logger::builder()
|
let filter = tracing_subscriber::EnvFilter::builder()
|
||||||
.set_level(app.verbosity.level())
|
.with_default_directive(tracing_subscriber::filter::LevelFilter::WARN.into())
|
||||||
.build()
|
.from_env()
|
||||||
.expect("could not init logging");
|
.expect("could not init logger")
|
||||||
|
.add_directive(
|
||||||
|
format!("rollator={}", app.verbosity.level())
|
||||||
|
.parse()
|
||||||
|
.expect("could not init logger"),
|
||||||
|
);
|
||||||
|
|
||||||
|
tracing_subscriber::fmt::Subscriber::builder()
|
||||||
|
.with_env_filter(filter)
|
||||||
|
.finish()
|
||||||
|
.set_default();
|
||||||
|
debug!("logging initialized!");
|
||||||
|
|
||||||
let native_options = eframe::NativeOptions {
|
let native_options = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
|
|
Loading…
Reference in New Issue