Parse-logger-config-text
Parse JSON text into a typed LoggerConfig. This API is useful when you want validation and inspection of config data before turning it into a runtime logger.
Interface
pub fn parse_logger_config_text(input : String) -> LoggerConfig raise ConfigError {}input
input : String- Raw JSON text matching the supported logger config schema.
output
LoggerConfig- Parsed typed configuration value.
Explanation
Detailed rules explaining key parameters and behaviors
- Parsing is separated from runtime construction.
- This API is ideal for validating, editing, or inspecting config values before calling
build_logger(...). - Supported keys are intentionally constrained to stable built-in sink shapes and formatter options.
- Omitted top-level keys fall back to the same defaults used by the typed config constructors:
min_level=Info,target="",timestamp=false,sink=default_sink_config(), andqueue=None. - When a
sinkobject is present, parsing selects the built-in sink kind and validates sink-specific data before any runtime logger is built. In particular,kind=Filerequires a non-emptypath. parse_and_build_logger(...)is only this parser plusbuild_logger(...), so using the two-step path here does not change the configured runtime pipeline.- The error surface is
ConfigErrorrather than silent fallback behavior.
How to Use
Here are some specific examples provided.
When Need Validation Before Runtime Build
When config should be reviewed before creating the logger:
let config = parse_logger_config_text(raw) catch {
err => return
}
let logger = build_logger(config)In this example, parsing and building remain separate phases.
When Need To Inspect Parsed Values
When config should be normalized into typed values first:
let config = parse_logger_config_text(raw) catch {
err => return
}
println(config.target)In this example, the parsed object can be inspected or rewritten before runtime use.
Error Case
e.g.:
If
inputis invalid JSON, parsing raisesConfigError.If supported fields have wrong types or unsupported enum text, parsing raises
ConfigError.If
sink.kindisFilebutsink.pathis empty, parsing raisesConfigErrorbefore runtime construction.
Notes
Prefer this API when you need typed config inspection before building.
Prefer
parse_and_build_logger(...)when one-step bootstrapping is enough.