diff --git a/src/fmt/mod.rs b/src/fmt/mod.rs index 771fd5c..faee69b 100644 --- a/src/fmt/mod.rs +++ b/src/fmt/mod.rs @@ -158,7 +158,11 @@ impl Write for Formatter { impl fmt::Debug for Formatter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Formatter").finish() + let buf = self.buf.borrow(); + f.debug_struct("Formatter") + .field("buf", &buf) + .field("write_style", &self.write_style) + .finish() } } diff --git a/src/fmt/writer/buffer.rs b/src/fmt/writer/buffer.rs index 89ad912..a7ea25b 100644 --- a/src/fmt/writer/buffer.rs +++ b/src/fmt/writer/buffer.rs @@ -2,6 +2,7 @@ use std::{io, sync::Mutex}; use crate::fmt::writer::WriteStyle; +#[derive(Debug)] pub(in crate::fmt::writer) struct BufferWriter { target: WritableTarget, write_style: WriteStyle, @@ -129,6 +130,12 @@ impl Buffer { } } +impl std::fmt::Debug for Buffer { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + String::from_utf8_lossy(self.as_bytes()).fmt(f) + } +} + /// Log target, either `stdout`, `stderr` or a custom pipe. /// /// Same as `Target`, except the pipe is wrapped in a mutex for interior mutability. diff --git a/src/fmt/writer/mod.rs b/src/fmt/writer/mod.rs index a3e6606..dbcf45b 100644 --- a/src/fmt/writer/mod.rs +++ b/src/fmt/writer/mod.rs @@ -2,7 +2,7 @@ mod buffer; mod target; use self::buffer::BufferWriter; -use std::{fmt, io, mem, sync::Mutex}; +use std::{io, mem, sync::Mutex}; pub(super) use self::buffer::Buffer; @@ -44,6 +44,7 @@ impl From for anstream::ColorChoice { } /// A terminal target with color awareness. +#[derive(Debug)] pub(crate) struct Writer { inner: BufferWriter, } @@ -62,12 +63,6 @@ impl Writer { } } -impl fmt::Debug for Writer { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Writer").finish() - } -} - /// A builder for a terminal writer. /// /// The target and style choice can be configured before building.