2.2 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| logger-config-to-json | api | config | 20260512 | Convert LoggerConfig into a JSON value for export, persistence, or generated config output. |
|
Logger-config-to-json
Convert a typed LoggerConfig into a JsonValue. This helper is the structured export path when config should be persisted, inspected, or embedded into larger JSON payloads.
Interface
pub fn logger_config_to_json(config : LoggerConfig) -> @json_parser.JsonValue {}
input
config : LoggerConfig- Typed logger configuration.
output
JsonValue- JSON representation of the logger config.
Explanation
Detailed rules explaining key parameters and behaviors
- The output includes
min_level,target,timestamp,sink, and optionalqueue. - Sink export is delegated to
sink_config_to_json(...). - The result is suitable for downstream JSON composition as well as stringification.
- Exported JSON follows the stable supported config schema rather than raw internal runtime state.
How to Use
Here are some specific examples provided.
When Need Generated Config Output
When code constructs config and later exports it:
let json = logger_config_to_json(LoggerConfig::new(target="svc"))
In this example, the typed config becomes a structured JSON value.
When Need To Embed Logger Config In A Larger Payload
When logger config should be one part of a bigger object:
let payload = logger_config_to_json(config)
In this example, the helper avoids re-implementing config serialization by hand.
Error Case
e.g.:
-
If
queueisNone, the exported JSON simply omits the queue field. -
If some sink options are unused by the chosen sink kind, they still follow the supported config export shape rather than a runtime-only interpretation.
Notes
Notes are here.
-
Use this API when you need a JSON value instead of text output.
-
Use
stringify_logger_config(...)for immediate string output. -
This helper complements
parse_logger_config_text(...)for roundtrip workflows. -
The output is configuration-oriented, not runtime-state-oriented.