refactor(log): remove annoying INFO logs on linux

This commit is contained in:
Christoph J. Scherr 2024-08-13 18:15:43 +02:00
parent 48d81d57b6
commit 5e4a1cbe5b
3 changed files with 37 additions and 12 deletions

View File

@ -26,3 +26,4 @@ clap = { version = "4.5.15", features = ["derive"] }
image = "0.25.2"
rand = "0.8.5"
rfd = "0.14.1"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

View File

@ -1,7 +1,7 @@
use clap::Parser;
use egui::IconData;
use libpt::cli::args::{VerbosityLevel, HELP_TEMPLATE};
use libpt::log::{debug, trace};
use libpt::log::trace;
pub const TITLE: &str = "Rollator";
@ -23,8 +23,9 @@ pub struct RollatorApp {
#[command(flatten)]
pub(crate) verbosity: VerbosityLevel,
/// open the informations window on start
#[serde(skip)]
#[clap(skip)]
#[arg(short = 'i', long = "info")]
show_info_window: bool,
}
@ -64,9 +65,9 @@ impl RollatorApp {
pub fn info_diag(&mut self, ctx: &egui::Context) {
trace!("rendering info dialogue");
ctx.show_viewport_immediate(
egui::ViewportId::from_hash_of("immediate_viewport"),
egui::ViewportId::from_hash_of(format!("{TITLE}: Information")),
egui::ViewportBuilder::default()
.with_title("Immediate Viewport")
.with_title(format!("{TITLE}: Information"))
.with_inner_size([500.0, 200.0]),
|ctx, class| {
assert!(
@ -75,7 +76,6 @@ impl RollatorApp {
);
egui::CentralPanel::default().show(ctx, |ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label(format!("{TITLE} v{}", env!("CARGO_PKG_VERSION")));
ui.hyperlink_to("Source Code\n", env!("CARGO_PKG_REPOSITORY"));
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) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.hyperlink_to("Source Code ", env!("CARGO_PKG_REPOSITORY"));
ui.label("| Powered by ");
ui.label(format!("{TITLE} v{}", env!("CARGO_PKG_VERSION")));
ui.label(" | Powered by ");
ui.hyperlink_to("egui", "https://github.com/emilk/egui");
ui.label(" and ");
ui.hyperlink_to(

View File

@ -6,12 +6,26 @@ mod app;
// When compiling natively:
#[cfg(not(target_arch = "wasm32"))]
fn main() -> eframe::Result {
use libpt::log::debug;
use tracing_subscriber::util::SubscriberInitExt;
let mut app = app::RollatorApp::new_with_cli();
let _logger = libpt::log::Logger::builder()
.set_level(app.verbosity.level())
.build()
.expect("could not init logging");
let filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive(tracing_subscriber::filter::LevelFilter::WARN.into())
.from_env()
.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 {
viewport: egui::ViewportBuilder::default()