Files
BitLogger/docs/api/stringify-file-sink-policy.md
T
2026-05-12 15:05:58 +08:00

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.
file
policy
stringify
public

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=false returns compact JSON.
  • pretty=true returns 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 JsonValue for composition rather than text, file_sink_policy_to_json(...) is the better API.

  • If rotation is disabled, the output still includes rotation as null.

Notes

  1. Use this helper for direct textual policy snapshots.

  2. pretty=true is useful when operators or support tooling are the audience.