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 | ||||
|---|---|---|---|---|---|---|---|---|---|
| parse-and-build-library-logger | api | facade | 20260520 | Parse JSON logger config text and build the library-facing sync logger facade. |
|
Parse-and-build-library-logger
Parse raw JSON config text and build a LibraryLogger[RuntimeSink] in one step. This facade is the text-driven library counterpart to parse_and_build_logger(...).
Interface
pub fn parse_and_build_library_logger(
input : String,
) -> LibraryLogger[RuntimeSink] raise ConfigError {
input
input : String- Raw JSON logger config text.
output
LibraryLogger[RuntimeSink]- Library-facing wrapper around the configured runtime logger.
Explanation
Detailed rules explaining key parameters and behaviors
- This API parses config text, validates it, builds the configured logger, and wraps it as a library facade.
- The returned facade keeps a narrower surface than the underlying configured logger.
to_logger()can be used to recover the underlying full logger object when necessary.
How to Use
Here are some specific examples provided.
When Need Text-driven Library Bootstrapping
When a reusable package wants config text input but a narrow logger facade output:
let logger = parse_and_build_library_logger(
"{\"min_level\":\"warn\",\"target\":\"lib\",\"sink\":{\"kind\":\"console\"}}",
)
In this example, parsing and library-facade construction happen in one call.
Error Case
e.g.:
-
If the JSON text is malformed, a
ConfigErroris raised. -
If the parsed config is invalid, a
ConfigErroris raised before the library facade is returned.
Notes
-
This is the narrow library-oriented parse-and-build sync entry point.
-
Use
build_library_logger(...)when the config is already typed.