datadog_formatting_layer/event_sink.rs
1use std::io::{stdout, Write};
2
3/// Something that can produce any sink for events
4pub trait EventSink {
5 /// Write an event to the sink
6 fn write(&self, event: String);
7}
8
9/// Default sink. Writes the messages to stdout
10#[non_exhaustive]
11#[derive(Default, Clone, Debug)]
12pub struct StdoutSink;
13
14impl EventSink for StdoutSink {
15 fn write(&self, mut event: String) {
16 // each line stdout is interpreted as a new log
17 event.push('\n');
18
19 #[allow(clippy::unwrap_used)]
20 stdout().write_all(event.as_bytes()).unwrap();
21 }
22}