Stringify-sink-config
Serialize SinkConfig into JSON text. This helper is the direct text output path for sink configuration when examples, tooling, or diagnostics want the sink section by itself.
Interface
pub fn stringify_sink_config(config : SinkConfig, pretty~ : Bool = false) -> String {}input
config : SinkConfig- Sink config to serialize.pretty : Bool- Whether output should be pretty-printed.
output
String- Serialized sink config JSON.
Explanation
Detailed rules explaining key parameters and behaviors
pretty=falsegives compact JSON.pretty=truegives indented output.- This helper builds on top of
sink_config_to_json(...). - Internally it serializes the
JsonValueresult with@json_parser.stringify(...)or@json_parser.stringify_pretty(value, 2), so the text form stays aligned with the structured sink export helper. - It is useful when examples or generated docs want to show only sink-specific config.
How to Use
Here are some specific examples provided.
When Need Human-readable Sink Config
When sink config should be printed for review:
println(stringify_sink_config(SinkConfig::new(kind=SinkKind::File, path="app.log"), pretty=true))In this example, the sink section is easy to inspect visually.
When Need Compact Embedded Output
When sink config should be emitted in a compact form:
println(stringify_sink_config(config.sink))In this example, the helper provides a ready-made machine-oriented representation.
Error Case
e.g.:
If callers need a JSON value instead of text, use
sink_config_to_json(...)instead.If optional
rotationis absent, the serialized sink config simply omits that field.
Notes
Use this helper when the next consumer expects JSON text instead of
JsonValue.Use
sink_config_to_json(...)when you still need to embed the sink config inside a larger JSON object before final stringification.