hyperlane_plugin_logger/struct.rs
1use super::*;
2
3/// The configuration of the logger.
4#[derive(Clone)]
5pub struct LoggerConfig {
6 /// The highest level that is written.
7 pub(crate) level: LevelFilter,
8 /// The file the log is appended to, when there is one.
9 pub(crate) file: Option<String>,
10 /// Whether formatted lines are also echoed to standard output.
11 pub(crate) console: bool,
12 /// Output line format (plain text or structured JSON).
13 pub(crate) format: LogFormat,
14 /// Bounded non-blocking channel capacity for background file writes.
15 pub(crate) channel_capacity: usize,
16 /// Optional custom extensible output sink invoked alongside built-in outputs.
17 pub(crate) sink: Option<Arc<dyn LogSink>>,
18}
19
20/// Streaming plain-text `fmt::Write` adapter sanitizing control bytes directly into a reusable buffer.
21pub(crate) struct PlainSanitizingWriter<'a> {
22 /// Target output string buffer.
23 pub(crate) out: &'a mut String,
24}
25
26/// Streaming JSON `fmt::Write` adapter escaping quotes, backslashes, and control bytes directly into a buffer.
27pub(crate) struct JsonSanitizingWriter<'a> {
28 /// Target output string buffer.
29 pub(crate) out: &'a mut String,
30}
31
32/// The plugin that writes the log of the server.
33#[derive(Clone, Copy, Debug, Default)]
34pub struct LoggerPlugin;
35
36/// The middleware that notes when a request arrived.
37#[derive(Clone, Copy, Debug, Default)]
38#[hyperlane::request_middleware(-120)]
39pub struct RequestLogger;
40
41/// The middleware that writes the line of an answered request.
42#[derive(Clone, Copy, Debug, Default)]
43#[hyperlane::response_middleware(100)]
44pub struct ResponseLogger;