A common use-case is to write colored (ANSI) logs to stdout and write non-colored logs to a file. Where that file may be forwarded to an aggregator, or viewed in an editor, which expects the contents to not have color formatting.
Solution
This PR updates the fmt-multiple-writers.rs example to demonstrate this use-case.
One additional change that's not related to what's described above is the printing of the log file contents to stdout after the example has finished shaving Yaks. The motive being that the log file TempDir is dropped after the example has finished. Currently, the end-user doesn't have a way to inspect the contents of the file without hopping into a debugger, modifying the example, or writing the file to a path that persists after execution.
Motivation
Related https://github.com/tokio-rs/tracing/issues/3116
A common use-case is to write colored (ANSI) logs to stdout and write non-colored logs to a file. Where that file may be forwarded to an aggregator, or viewed in an editor, which expects the contents to not have color formatting.
Solution
This PR updates the
fmt-multiple-writers.rs
example to demonstrate this use-case.One additional change that's not related to what's described above is the printing of the log file contents to stdout after the example has finished shaving Yaks. The motive being that the log file
TempDir
is dropped after the example has finished. Currently, the end-user doesn't have a way to inspect the contents of the file without hopping into a debugger, modifying the example, or writing the file to a path that persists after execution.Example Output