3.9 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| build-application-text-async-logger | api | facade | 20260614 | Build the application-facing text-console async logger alias from an AsyncLoggerBuildConfig using the configured text formatter directly. |
|
Build-application-text-async-logger
Build an ApplicationTextAsyncLogger from AsyncLoggerBuildConfig. This is the application-oriented async alias builder for the text-console runtime sink shape returned by build_async_text_logger(...).
Interface
pub fn build_application_text_async_logger(
config : AsyncLoggerBuildConfig,
) -> ApplicationTextAsyncLogger {
input
config : AsyncLoggerBuildConfig- Combined sync logger config and async queue/runtime config.
output
ApplicationTextAsyncLogger- Application-facing async logger backed byFormattedConsoleSink.
Explanation
Detailed rules explaining key parameters and behaviors
- This API delegates to
build_async_text_logger(...)directly. - It is intended for config-driven async text console output where callers want the concrete text sink shape rather than the broader runtime sink enum wrapper.
- The builder always creates a
FormattedConsoleSinkfromconfig.logger.sink.text_formatterinstead of selecting among sink kinds. - Unlike
build_application_async_logger(...), this alias-oriented builder does not go through the full synchronous configured-logger build path first. - It uses the selected text-oriented
LoggerConfigfields directly and therefore does not applyLoggerConfig.queueor preserve sync runtime sink controls. - Because the result is only the
ApplicationTextAsyncLoggeralias overAsyncLogger[@bitlogger.FormattedConsoleSink], this builder does not hide any async helpers or introduce a wrapper layer. - The returned logger keeps the full async lifecycle and state helper surface directly, including helpers such as
run(),shutdown(),pending_count(),dropped_count(),state(),wait_idle(),has_failed(), andlast_error(). - It also keeps the same runtime-dependent close/failure semantics as the underlying
AsyncLogger[@bitlogger.FormattedConsoleSink].
How to Use
Here are some specific examples provided.
When Need An App Async Builder With Text Sink Shape
When async output should stay on text console formatting:
let logger = build_application_text_async_logger(
AsyncLoggerBuildConfig::new(
logger=text_console(target="app.text.async"),
async_config=AsyncLoggerConfig::new(max_pending=4),
),
)
In this example, the async logger is built for text-console output specifically.
When Need Async State Helpers Immediately After Text App Construction
When application code should keep the ordinary async helper surface directly on the text-console variant:
let logger = build_application_text_async_logger(config)
ignore(logger.pending_count())
ignore(logger.state())
In this example, the application text alias exposes async state helpers directly because no narrowing wrapper is added.
Error Case
e.g.:
-
If callers need sink-kind-driven branching such as JSON console or file-backed async output, they should use
build_application_async_logger(...)instead. -
If runtime draining is never started, records still follow the normal async queue lifecycle rules.
Notes
-
This is a narrower text-console async facade than
build_application_async_logger(...). -
It is most useful when callers want the
FormattedConsoleSink-backed async type explicitly. -
Use
build_application_async_logger(...)instead when callers need the broader runtime-sink build path, including sync queue application throughbuild_logger(config.logger). -
Use
build_library_async_text_logger(...)instead when the public boundary should narrow the exposed async surface while preserving the same concrete text sink type.