Update fmt-multiple-writers.rs example #3139
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Related #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