2.6 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| build-library-async-text-logger | api | facade | 20260614 | Build the library-facing text-console async logger facade from an AsyncLoggerBuildConfig using the configured text formatter directly. |
|
Build-library-async-text-logger
Build a LibraryAsyncLogger[FormattedConsoleSink] from AsyncLoggerBuildConfig. This facade is the library-oriented async builder for text-console runtime output.
Interface
pub fn build_library_async_text_logger(
config : AsyncLoggerBuildConfig,
) -> LibraryAsyncLogger[FormattedConsoleSink] {
input
config : AsyncLoggerBuildConfig- Combined sync logger config and async queue/runtime config.
output
LibraryAsyncLogger[FormattedConsoleSink]- Library-facing async logger backed by formatted console output.
Explanation
Detailed rules explaining key parameters and behaviors
- This API delegates to
build_async_text_logger(...)and then wraps the result asLibraryAsyncLogger. - It always produces a concrete
FormattedConsoleSinkfromconfig.logger.sink.text_formatterinstead of selecting among sink kinds. - Unlike
build_library_async_logger(...), this facade 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. - It is useful when library code wants a narrow async facade while preserving a concrete text-console sink type.
to_async_logger()can recover the underlying full async logger if needed.
How to Use
Here are some specific examples provided.
When Need A Narrow Async Text Logger For Libraries
When a library wants text-console async output and a narrower public type:
let logger = build_library_async_text_logger(
AsyncLoggerBuildConfig::new(
logger=text_console(target="lib.text.async"),
async_config=AsyncLoggerConfig::new(max_pending=4),
),
)
In this example, the async text sink shape is preserved under the library facade.
Error Case
e.g.:
-
If callers need sink-kind-driven branching such as JSON console or file-backed async output, they should use
build_library_async_logger(...)instead. -
Normal async lifecycle expectations still apply if the logger is never run.
Notes
-
This is the library-side counterpart to
build_application_text_async_logger(...). -
It is most useful when a concrete text-console async sink type matters to the caller boundary.