Files
BitLogger/docs/api/build-application-text-async-logger.md
T
2026-06-14 01:30:22 +08:00

4.2 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 direct concrete text-sink builder path.
application
async
text
public

Build-application-text-async-logger

Build an ApplicationTextAsyncLogger from AsyncLoggerBuildConfig. This is the application-oriented async alias builder for the concrete text-console 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 by FormattedConsoleSink.

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 FormattedConsoleSink from config.logger.sink.text_formatter instead 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 LoggerConfig fields directly and therefore does not apply LoggerConfig.queue or preserve sync runtime sink controls.
  • Because the result is only the ApplicationTextAsyncLogger alias over AsyncLogger[@bitlogger.FormattedConsoleSink], this builder returns the same underlying async logger value as build_async_text_logger(...) and 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(), and last_error().
  • It also keeps the same runtime-dependent close/failure semantics as the underlying AsyncLogger[@bitlogger.FormattedConsoleSink].
  • Use build_library_async_text_logger(...) instead when the next boundary should keep the same concrete text sink type but intentionally narrow the directly exposed async helper surface.

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

  1. This is a narrower text-console async facade than build_application_async_logger(...).

  2. It is most useful when callers want the FormattedConsoleSink-backed async type explicitly.

  3. Use build_application_async_logger(...) instead when callers need the broader runtime-sink build path, including sync queue application through build_logger(config.logger).

  4. 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.