Skip to content

Commit

Permalink
fix: ChildApp Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Easyoakland committed Dec 8, 2023
1 parent b7ebb8e commit 38e2942
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/child_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ 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 {
Some(_) => &"Running",
None => &"Killed",
},
)
.field("logger", &self.logger)
.finish()
}
}
Expand Down Expand Up @@ -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()
}
Expand Down
11 changes: 10 additions & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,6 +17,12 @@ pub struct Logger {
pub(crate) queue: Mutex<Vec<String>>,
}

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`].
///
Expand Down

0 comments on commit 38e2942

Please sign in to comment.