From 38e2942b0301cc52575a8458fd037f71d02453b3 Mon Sep 17 00:00:00 2001 From: Easyoakland <97992568+Easyoakland@users.noreply.github.com> Date: Wed, 29 Nov 2023 07:12:22 -0700 Subject: [PATCH] fix: ChildApp `Debug` --- src/child_app.rs | 9 +++++---- src/logger.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/child_app.rs b/src/child_app.rs index 5db901c..02379b0 100644 --- a/src/child_app.rs +++ b/src/child_app.rs @@ -36,6 +36,7 @@ pub struct ChildApp { impl Debug for ChildApp { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("ChildApp") + .field("ctx", &self.ctx) .field( "fut", match self.fut { @@ -43,6 +44,7 @@ impl Debug for ChildApp { None => &"Killed", }, ) + .field("logger", &self.logger) .finish() } } @@ -75,10 +77,9 @@ impl ChildApp { .queue .lock() .drain(..) - .map(|x| { - let mut out = x; - out.push('\n'); // Concatenate messages with newlines - out + .map(|mut x| { + x.push('\n'); // Concatenate messages with newlines + x }) .collect() } diff --git a/src/logger.rs b/src/logger.rs index 45b873e..03a2c3b 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -1,6 +1,9 @@ use eframe::epaint::mutex::Mutex; use log::LevelFilter; -use std::sync::{Arc, OnceLock}; +use std::{ + fmt::Debug, + sync::{Arc, OnceLock}, +}; /// The [`Logger`]. It is static so it can be changed from outside klask from anywhere using [`Logger::set_max_level`]. // Only needed because [`log`] doesn't give direct access to the global boxed logger. @@ -14,6 +17,12 @@ pub struct Logger { pub(crate) queue: Mutex>, } +impl Debug for Logger { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Logger").finish_non_exhaustive() + } +} + impl Logger { /// Initialize the [`Logger`] with the given [`LevelFilter`]. ///