Skip to content

Commit 7cf745c

Browse files
authored
Make format::Writer::new() public
A number of people (myself included) have expressed significant interest in having Writer::new() public for various reasons, with some difficulty getting traction.
1 parent 941b159 commit 7cf745c

File tree

1 file changed

+6
-1
lines changed
  • tracing-subscriber/src/fmt/format

1 file changed

+6
-1
lines changed

tracing-subscriber/src/fmt/format/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,12 @@ impl<'writer> Writer<'writer> {
423423
// We may not want to do that if we choose to expose specialized
424424
// constructors instead (e.g. `from_string` that stores whether the string
425425
// is empty...?)
426-
pub(crate) fn new(writer: &'writer mut impl fmt::Write) -> Self {
426+
//(@kaifastromai) I suppose having dedicated constructors may have certain benefits
427+
// but I am not privy to the larger direction of tracing/subscriber.
428+
///Create a new [`Writer`] from any type that implements fmt::Write.
429+
///This can be used to e.g. obtain the raw string after this writer has formatted via a call to `[fmt::format::Format::format_event]
430+
#[must_use]
431+
pub fn new(writer: &'writer mut impl fmt::Write) -> Self {
427432
Self {
428433
writer: writer as &mut dyn fmt::Write,
429434
is_ansi: false,

0 commit comments

Comments
 (0)