diff --git a/src/lib.rs b/src/lib.rs index 9597ae8..48ee752 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ use std::mem::MaybeUninit; use std::sync::OnceLock; use crate::arrays::{fill_tag_bytes, uninit_array}; -use crate::platform_log_writer::PlatformLogWriter; +pub use crate::platform_log_writer::PlatformLogWriter; pub use config::Config; pub use env_filter::{Builder as FilterBuilder, Filter}; pub use id::LogId; @@ -202,9 +202,6 @@ impl Log for AndroidLogger { ), _ => fmt::write(&mut writer, *record.args()), }; - - // output the remaining message (this would usually be the most common case) - writer.flush(); } fn flush(&self) {} diff --git a/src/platform_log_writer.rs b/src/platform_log_writer.rs index 2a7b53a..a27d78a 100644 --- a/src/platform_log_writer.rs +++ b/src/platform_log_writer.rs @@ -187,6 +187,12 @@ impl fmt::Write for PlatformLogWriter<'_> { } } +impl Drop for PlatformLogWriter<'_> { + fn drop(&mut self) { + self.flush(); + } +} + #[cfg(test)] pub mod tests { use crate::arrays::slice_assume_init_ref;