Skip to content

Commit 946895a

Browse files
CLEckhardtdavidbarsky
authored andcommitted
appender: clarify file appender docs (#2689)
## Motivation There are a few errors in the file appender docs - this fixes them. It also wasn't clear/apparent to me that you can create a non-rolling file appender with the `rolling` module - this calls that out more clearly. ## Solution Updates to docs.
1 parent 2d82c04 commit 946895a

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

tracing-appender/src/lib.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,34 @@
2626
//! - Using a combination of [`NonBlocking`][non_blocking] and [`RollingFileAppender`][rolling_struct] to allow writes to a log file
2727
//! without blocking.
2828
//!
29-
//! ## Rolling File Appender
29+
//! ## File Appender
30+
//!
31+
//! The [`rolling` module][rolling] provides functions to create rolling and non-rolling file
32+
//! appenders.
33+
//!
34+
//! Rolling file appender rotation options are [`Rotation::MINUTELY`](rolling::Rotation::MINUTELY),
35+
//! [`Rotation::HOURLY`](rolling::Rotation::HOURLY), and
36+
//! [`Rotation::DAILY`](rolling::Rotation::DAILY).
37+
//!
38+
//! To create a non-rolling file appender, use
39+
//! [`tracing_appender::rolling::never(/*...*/)`](rolling::never) or
40+
//! [`Rotation::NEVER`](rolling::Rotation::NEVER).
41+
//!
42+
//! The following example creates an hourly rotating file appender that writes to
43+
//! `/some/directory/prefix.log.YYYY-MM-DD-HH`:
3044
//!
3145
//! ```rust
3246
//! # fn docs() {
3347
//! let file_appender = tracing_appender::rolling::hourly("/some/directory", "prefix.log");
3448
//! # }
3549
//! ```
36-
//! This creates an hourly rotating file appender that writes to `/some/directory/prefix.log.YYYY-MM-DD-HH`.
37-
//! [`Rotation::DAILY`](rolling::Rotation::DAILY) and [`Rotation::NEVER`](rolling::Rotation::NEVER) are the other available options.
3850
//!
39-
//! The file appender implements [`std::io::Write`][write]. To be used with [`tracing_subscriber::FmtSubscriber`][fmt_subscriber],
40-
//! it must be combined with a [`MakeWriter`][make_writer] implementation to be able to record tracing spans/event.
51+
//! The file appender implements [`std::io::Write`][write]. To be used with
52+
//! [`tracing_subscriber::FmtSubscriber`][fmt_subscriber], it must be combined with a
53+
//! [`MakeWriter`][make_writer] implementation to be able to record tracing spans/event.
4154
//!
42-
//! The [`rolling` module][rolling]'s documentation provides more detail on how to use this file appender.
55+
//! See the [`rolling` module][rolling]'s documentation for more detail on how to use this file
56+
//! appender.
4357
//!
4458
//! ## Non-Blocking Writer
4559
//!

tracing-appender/src/rolling.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl fmt::Debug for RollingFileAppender {
264264
}
265265
}
266266

267-
/// Creates a minutely, rolling file appender. This will rotate the log file once per minute.
267+
/// Creates a minutely-rotating file appender. This will rotate the log file once per minute.
268268
///
269269
/// The appender returned by `rolling::minutely` can be used with `non_blocking` to create
270270
/// a non-blocking, minutely file appender.
@@ -299,7 +299,7 @@ pub fn minutely(
299299
RollingFileAppender::new(Rotation::MINUTELY, directory, file_name_prefix)
300300
}
301301

302-
/// Creates an hourly, rolling file appender.
302+
/// Creates an hourly-rotating file appender.
303303
///
304304
/// The appender returned by `rolling::hourly` can be used with `non_blocking` to create
305305
/// a non-blocking, hourly file appender.
@@ -334,7 +334,7 @@ pub fn hourly(
334334
RollingFileAppender::new(Rotation::HOURLY, directory, file_name_prefix)
335335
}
336336

337-
/// Creates a file appender that rotates daily.
337+
/// Creates a daily-rotating file appender.
338338
///
339339
/// The appender returned by `rolling::daily` can be used with `non_blocking` to create
340340
/// a non-blocking, daily file appender.
@@ -370,13 +370,13 @@ pub fn daily(
370370
RollingFileAppender::new(Rotation::DAILY, directory, file_name_prefix)
371371
}
372372

373-
/// Creates a non-rolling, file appender
373+
/// Creates a non-rolling file appender.
374374
///
375375
/// The appender returned by `rolling::never` can be used with `non_blocking` to create
376376
/// a non-blocking, non-rotating appender.
377377
///
378378
/// The location of the log file will be specified the `directory` passed in.
379-
/// `file_name` specifies the prefix of the log file. No date or time is appended.
379+
/// `file_name` specifies the complete name of the log file (no date or time is appended).
380380
///
381381
/// # Examples
382382
///

0 commit comments

Comments
 (0)