-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/log-line-number-and-filename
- Loading branch information
Showing
10 changed files
with
333 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! This example demonstrates the use of multiple files with | ||
//! `tracing-appender`'s `RollingFileAppender` | ||
//! | ||
use tracing_appender::rolling; | ||
use tracing_subscriber::fmt::writer::MakeWriterExt; | ||
|
||
#[path = "fmt/yak_shave.rs"] | ||
mod yak_shave; | ||
|
||
fn main() { | ||
// Log all `tracing` events to files prefixed with `debug`. Since these | ||
// files will be written to very frequently, roll the log file every minute. | ||
let debug_file = rolling::minutely("./logs", "debug"); | ||
// Log warnings and errors to a separate file. Since we expect these events | ||
// to occur less frequently, roll that file on a daily basis instead. | ||
let warn_file = rolling::daily("./logs", "warnings").with_max_level(tracing::Level::WARN); | ||
let all_files = debug_file.and(warn_file); | ||
|
||
tracing_subscriber::fmt() | ||
.with_writer(all_files) | ||
.with_ansi(false) | ||
.with_max_level(tracing::Level::TRACE) | ||
.init(); | ||
|
||
yak_shave::shave_all(6); | ||
tracing::info!("sleeping for a minute..."); | ||
|
||
std::thread::sleep(std::time::Duration::from_secs(60)); | ||
|
||
tracing::info!("okay, time to shave some more yaks!"); | ||
yak_shave::shave_all(10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.