Skip to content

Commit bc02d61

Browse files
committed
feat(fmt): Expose ConfigurableFormat
1 parent c567fde commit bc02d61

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/fmt/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,9 @@ impl<T: Display> Display for StyledValue<T> {
276276
#[cfg(not(feature = "color"))]
277277
type StyledValue<T> = T;
278278

279-
/// The default format.
280-
///
281-
/// This format needs to work with any combination of crate features.
282-
pub(crate) struct ConfigurableFormat {
279+
/// A [custom format][crate::Builder::format] with settings for which fields to show
280+
pub struct ConfigurableFormat {
281+
// This format needs to work with any combination of crate features.
283282
pub(crate) timestamp: Option<TimestampPrecision>,
284283
pub(crate) module_path: bool,
285284
pub(crate) target: bool,
@@ -294,7 +293,7 @@ pub(crate) struct ConfigurableFormat {
294293

295294
impl ConfigurableFormat {
296295
/// Format the [`Record`] as configured for outputting
297-
pub(crate) fn format(&self, formatter: &mut Formatter, record: &Record<'_>) -> io::Result<()> {
296+
pub fn format(&self, formatter: &mut Formatter, record: &Record<'_>) -> io::Result<()> {
298297
let fmt = ConfigurableFormatWriter {
299298
format: self,
300299
buf: formatter,
@@ -307,52 +306,52 @@ impl ConfigurableFormat {
307306

308307
impl ConfigurableFormat {
309308
/// Whether or not to write the level in the default format.
310-
pub(crate) fn level(&mut self, write: bool) -> &mut Self {
309+
pub fn level(&mut self, write: bool) -> &mut Self {
311310
self.level = write;
312311
self
313312
}
314313

315314
/// Whether or not to write the source file path in the default format.
316-
pub(crate) fn file(&mut self, write: bool) -> &mut Self {
315+
pub fn file(&mut self, write: bool) -> &mut Self {
317316
self.source_file = write;
318317
self
319318
}
320319

321320
/// Whether or not to write the source line number path in the default format.
322321
///
323322
/// Only has effect if `format_file` is also enabled
324-
pub(crate) fn line_number(&mut self, write: bool) -> &mut Self {
323+
pub fn line_number(&mut self, write: bool) -> &mut Self {
325324
self.source_line_number = write;
326325
self
327326
}
328327

329328
/// Whether or not to write the module path in the default format.
330-
pub(crate) fn module_path(&mut self, write: bool) -> &mut Self {
329+
pub fn module_path(&mut self, write: bool) -> &mut Self {
331330
self.module_path = write;
332331
self
333332
}
334333

335334
/// Whether or not to write the target in the default format.
336-
pub(crate) fn target(&mut self, write: bool) -> &mut Self {
335+
pub fn target(&mut self, write: bool) -> &mut Self {
337336
self.target = write;
338337
self
339338
}
340339

341340
/// Configures the amount of spaces to use to indent multiline log records.
342341
/// A value of `None` disables any kind of indentation.
343-
pub(crate) fn indent(&mut self, indent: Option<usize>) -> &mut Self {
342+
pub fn indent(&mut self, indent: Option<usize>) -> &mut Self {
344343
self.indent = indent;
345344
self
346345
}
347346

348347
/// Configures if timestamp should be included and in what precision.
349-
pub(crate) fn timestamp(&mut self, timestamp: Option<TimestampPrecision>) -> &mut Self {
348+
pub fn timestamp(&mut self, timestamp: Option<TimestampPrecision>) -> &mut Self {
350349
self.timestamp = timestamp;
351350
self
352351
}
353352

354353
/// Configures the end of line suffix.
355-
pub(crate) fn suffix(&mut self, suffix: &'static str) -> &mut Self {
354+
pub fn suffix(&mut self, suffix: &'static str) -> &mut Self {
356355
self.suffix = suffix;
357356
self
358357
}
@@ -368,7 +367,7 @@ impl ConfigurableFormat {
368367
/// The default format uses a space to separate each key-value pair, with an "=" between
369368
/// the key and value.
370369
#[cfg(feature = "kv")]
371-
pub(crate) fn key_values<F>(&mut self, format: F) -> &mut Self
370+
pub fn key_values<F>(&mut self, format: F) -> &mut Self
372371
where
373372
F: Fn(&mut Formatter, &dyn log::kv::Source) -> io::Result<()> + Sync + Send + 'static,
374373
{

0 commit comments

Comments
 (0)