Skip to content

more backports #1767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions examples/examples/appender-multifile.rs
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);
}
1 change: 1 addition & 0 deletions tracing-appender/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rust-version = "1.51.0"
[dependencies]
crossbeam-channel = "0.5.0"
time = { version = "0.3", default-features = false, features = ["formatting"] }
parking_lot = { optional = true, version = "0.11.2" }

[dependencies.tracing-subscriber]
path = "../tracing-subscriber"
Expand Down
105 changes: 0 additions & 105 deletions tracing-appender/src/inner.rs

This file was deleted.

4 changes: 2 additions & 2 deletions tracing-appender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ use crate::non_blocking::{NonBlocking, WorkerGuard};

use std::io::Write;

mod inner;

pub mod non_blocking;

pub mod rolling;

mod worker;

pub(crate) mod sync;

/// Convenience function for creating a non-blocking, off-thread writer.
///
/// See the [`non_blocking` module's docs][non_blocking]'s for more details.
Expand Down
Loading