1.9 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| stringify-file-sink-policy | api | runtime | 20260512 | Serialize FileSinkPolicy into compact or pretty JSON text for diagnostics and policy snapshots. |
|
Stringify-file-sink-policy
Serialize FileSinkPolicy into JSON text. This helper is the most direct export path for runtime file policy snapshots.
Interface
pub fn stringify_file_sink_policy(policy : FileSinkPolicy, pretty~ : Bool = false) -> String {}
input
policy : FileSinkPolicy- File sink runtime policy to serialize.pretty : Bool- Whether JSON should be pretty-printed.
output
String- Serialized JSON text for the file policy.
Explanation
Detailed rules explaining key parameters and behaviors
pretty=falsereturns compact JSON.pretty=truereturns indented JSON for human inspection.- This helper builds on top of
file_sink_policy_to_json(...). - The output is suited for support dumps, policy snapshots, and generated diagnostics text.
How to Use
Here are some specific examples provided.
When Need Human-readable Policy Output
When current file policy should be printed for diagnostics:
println(stringify_file_sink_policy(sink.policy(), pretty=true))
In this example, the runtime file policy is rendered in readable JSON.
When Need Compact Policy Export
When a file policy snapshot should stay small:
let text = stringify_file_sink_policy(sink.policy())
In this example, compact JSON is produced without extra formatting logic.
Error Case
e.g.:
-
If callers need a
JsonValuefor composition rather than text,file_sink_policy_to_json(...)is the better API. -
If rotation is disabled, the output still includes
rotationasnull.
Notes
-
Use this helper for direct textual policy snapshots.
-
pretty=trueis useful when operators or support tooling are the audience.