Parse-and-build-application-async-logger
Parse raw JSON async build config text and build an ApplicationAsyncLogger in one step. This is the application-oriented counterpart to parse_async_logger_build_config_text(...) plus build_application_async_logger(...).
Interface
pub fn parse_and_build_application_async_logger(
input : String,
) -> ApplicationAsyncLogger raise {input
input : String- Raw JSON async logger build config text.
output
ApplicationAsyncLogger- Application-facing async runtime logger.
Explanation
Detailed rules explaining key parameters and behaviors
- This API parses async build config text first, then builds the application async logger through
build_application_async_logger(...). - Both the embedded sync logger config and async queue/runtime config are validated by the parser layer.
- The embedded
LoggerConfigis then built through the normal synchronous config path before the outer async layer is applied. - Any optional synchronous queue layer and configured runtime controls remain active inside the returned
AsyncRuntimeSinkwrapper. - The sync config path applies a parsed queue setting and selects the underlying
RuntimeSinkvariant beforeAsyncRuntimeSinkwraps that shared state. - Because the result is the
ApplicationAsyncLoggeralias overAsyncLogger[AsyncRuntimeSink], this path returns the same async logger asparse_async_logger_build_config_text(...)followed bybuild_async_logger(...), without narrowing the helper surface. - The async helper surface remains directly exposed on the returned alias; file-backed runtime controls are provided through its
AsyncRuntimeSink. - The returned logger keeps the full async lifecycle and state helpers directly.
- The returned logger also keeps the ordinary async logger target rules unchanged:
log(..., target=...)can override the target for one call, while severity helpers such asinfo(...),warn(...), anderror(...)continue to use the stored logger target unless a derived logger was created first withwith_target(...)orchild(...). - In the current parsed-builder coverage, that direct equivalence also holds for serialized async state snapshots, async sink-kind choice, queue counters, lifecycle flags, and later failure fields after worker execution.
- Parsed file-backed runtime helpers remain available through the returned logger's
AsyncRuntimeSink, matching the directbuild_async_logger(parse_async_logger_build_config_text(input))path.
How to Use
Here are some specific examples provided.
When Need App Async Boot Directly From JSON
When async config is sourced as text and should become a running-capable facade immediately:
let logger = parse_and_build_application_async_logger(
"{\"logger\":{\"target\":\"app.async\",\"sink\":{\"kind\":\"console\"}},\"async_config\":{\"max_pending\":4,\"overflow\":\"DropNewest\",\"max_batch\":1,\"linger_ms\":0,\"flush\":\"Never\"}}",
)In this example, text parsing and async logger construction happen in one facade call.
Configured synchronous runtime controls remain available through the returned AsyncRuntimeSink-backed async logger.
And unlike parse_and_build_library_async_logger(...), no to_async_logger() unwrap is required to reach async queue and lifecycle helpers or the AsyncRuntimeSink file controls.
When Need Async State Helpers After JSON-driven App Construction
When application boot should parse JSON text and still keep direct access to async helper APIs:
let logger = parse_and_build_application_async_logger(raw) catch {
err => return
}
ignore(logger.pending_count())
ignore(logger.state())In this example, no unwrap step is needed because the application result is an alias, not a narrowing facade.
When Need A Per-call Target Override After JSON Boot
When parsed app configuration should keep the same direct target override behavior as the ordinary async logger:
let logger = parse_and_build_application_async_logger(raw) catch {
err => return
}
logger.log(@bitlogger.Level::Error, "boom", target="app.audit")In this example, the emitted record uses app.audit for that call.
And later info(...), warn(...), or error(...) calls still use the logger's stored target unless code derives another logger first with with_target(...) or child(...).
Error Case
e.g.:
If the JSON text is malformed, parsing raises an error.
If the embedded config is invalid, parsing raises before the async facade is returned.
If callers depend on file-backed runtime helpers, they can use them through the returned logger's
AsyncRuntimeSinkwrapper.If callers depend on queued or file-backed runtime behavior, this facade preserves the sync-first sink selection and queue setup inside
AsyncRuntimeSink; it does not expose a rootRuntimeSinkdirectly.
Notes
Use this facade when application boot starts from JSON text.
Use
build_application_async_logger(...)when config is already typed asAsyncLoggerBuildConfig.Use
parse_and_build_library_async_logger(...)instead when text-driven construction should narrow the public async surface for a library boundary.