mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
1.8 KiB
1.8 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. |
|
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=falseproduces compact JSON.pretty=trueproduces 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.