Files
BitLogger/docs/api/stringify-logger-config.md
T
2026-05-12 13:20:36 +08:00

2.0 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
stringify-logger-config api config 20260512 Serialize LoggerConfig into compact or pretty JSON text for persistence and diagnostics.
logger
config
stringify
public

Stringify-logger-config

Serialize LoggerConfig into JSON text. This is the easiest way to emit typed logger configuration as a string for persistence, examples, diagnostics, or generated config files.

Interface

pub fn stringify_logger_config(config : LoggerConfig, pretty~ : Bool = false) -> String {}

input

  • config : LoggerConfig - Config to serialize.
  • pretty : Bool - Whether JSON output should be pretty-printed.

output

  • String - Serialized logger config JSON.

Explanation

Detailed rules explaining key parameters and behaviors

  • pretty=false produces compact JSON.
  • pretty=true produces indented human-readable JSON.
  • This helper builds on top of logger_config_to_json(...).
  • Output is stable and suited for roundtrip config workflows.

How to Use

Here are some specific examples provided.

When Need A Human-readable Generated Config

When config should be printed or checked by humans:

println(stringify_logger_config(config, pretty=true))

In this example, the output is readable enough for documentation or operator inspection.

When Need Compact Export

When config should be emitted as a compact payload:

println(stringify_logger_config(config))

In this example, the config stays small and machine-oriented.

Error Case

e.g.:

  • If callers need a JSON value rather than text, use logger_config_to_json(...) instead.

  • If config contains optional queue=None, the output omits that section rather than failing.

Notes

Notes are here.

  1. This API is ideal for generated examples and stored config payloads.

  2. Use pretty=true when readability matters.

  3. Pair with parse_logger_config_text(...) for roundtrip validation workflows.

  4. The output describes config, not runtime sink state.