1.9 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| stringify-sink-config | api | config | 20260512 | Serialize SinkConfig into compact or pretty JSON text. |
|
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(...). - 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
-
This helper is convenient for documentation, examples, and generated config output.
-
Use
pretty=truewhen humans are the primary audience.