tracing
tracing copied to clipboard
appender: Add appender to write same log line to multiple outputs in a loop.
Motivation
tracing currently doesn't have a way to send the same log line to multiple appenders at the same time.
Solution
This is a very quick implementation of an appender that wraps an arbitrary number of other appenders and writes the same log line to all of them in a loop.
I didn't write any tests for this module because it legitimately doesn't do anything except call the implementations of its inner writers, so there's really nothing testable here.
Could you also consider the use-case where you need to have different filters for different writers? I want to report only WARN+ logs in human-readable format to stderr while writing DEBUG+ messages in JSON format to some local file and INFO+ logs to centralized logs storage (e.g. graylog, or other solution which requires its own serialization format).
This solution does not seem to be able to fulfill the requirements, right?
I find Python logging being quite flexible: https://docs.python.org/3/howto/logging.html#advanced-logging-tutorial
Could you also consider the use-case where you need to have different filters for different writers? I want to report only WARN+ logs in human-readable format to stderr while writing DEBUG+ messages in JSON format to some local file and INFO+ logs to centralized logs storage (e.g. graylog, or other solution which requires its own serialization format).
You're right, this PR doesn't allow you to selectively filter on a per-layer basis. That use case will be addressed in https://github.com/tokio-rs/tracing/pull/508.
@SriRamanujam - Should we close this PR? cc @hawkw