mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
1.6 KiB
1.6 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| fanout-sink | api | sink | 20260520 | Create a sink that writes each record to two sinks. |
|
Fanout-sink
Create a sink that writes every record to two underlying sinks. This helper is useful when the same log stream should be duplicated across multiple destinations.
Interface
pub fn[A, B] fanout_sink(left : A, right : B) -> FanoutSink[A, B] {
input
left : A- First sink destination.right : B- Second sink destination.
output
FanoutSink[A, B]- Sink that duplicates records to both destinations.
Explanation
Detailed rules explaining key parameters and behaviors
- Each record is written to both sinks.
- The right side receives a copied record so the two writes remain independent at the record value level.
- This helper is useful for combinations such as console plus JSON, or console plus callback capture.
How to Use
Here are some specific examples provided.
When Need Dual Output Paths
When the same records should go to both human and machine-oriented outputs:
let logger = Logger::new(
fanout_sink(console_sink(), json_console_sink()),
target="dual",
)
In this example, each record is written to both console sinks.
Error Case
e.g.:
-
If only one path should receive a record conditionally, use
split_sink(...)instead. -
Sink-specific failures still follow the behavior of the wrapped sinks.
Notes
-
This helper is a duplication primitive, not a conditional router.
-
It is often useful in examples and test capture setups.