From d23e3263158e0aa2f218b6eddac17d42bbc7d8b6 Mon Sep 17 00:00:00 2001 From: Nanaloveyuki Date: Sun, 14 Jun 2026 02:25:11 +0800 Subject: [PATCH] :white_check_mark: cover application text async builder path --- docs/api/application-text-async-logger.md | 1 + .../build-application-text-async-logger.md | 1 + src-async/BitLoggerAsync_test.mbt | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/docs/api/application-text-async-logger.md b/docs/api/application-text-async-logger.md index 2522c55..6ad2e72 100644 --- a/docs/api/application-text-async-logger.md +++ b/docs/api/application-text-async-logger.md @@ -34,6 +34,7 @@ Detailed rules explaining key parameters and behaviors - Because this is only an alias, methods that are async on `AsyncLogger[@bitlogger.FormattedConsoleSink]` remain async here as well. - The alias therefore keeps the same text-console-specific builder and lifecycle semantics already documented on `AsyncLogger[@bitlogger.FormattedConsoleSink]`, including the concrete sink shape and runtime-dependent close/failure behavior. - The application-facing type does not hide any async state or lifecycle helpers; queue/backlog/failure inspection remains directly available on this alias just as it is on the underlying `AsyncLogger[@bitlogger.FormattedConsoleSink]`. +- When the value is built through `build_application_text_async_logger(...)`, the direct async counters come from the outer async logger only; any optional sync queue configured on `LoggerConfig.queue` is not carried into this text-specific build path. - The alias exists to give application code a clearer public name when it wants the concrete text-console sink shape explicitly. - `build_application_text_async_logger(...)` returns this alias. diff --git a/docs/api/build-application-text-async-logger.md b/docs/api/build-application-text-async-logger.md index ac9c502..33f1713 100644 --- a/docs/api/build-application-text-async-logger.md +++ b/docs/api/build-application-text-async-logger.md @@ -40,6 +40,7 @@ Detailed rules explaining key parameters and behaviors - 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. +- A sync queue configured on `LoggerConfig.queue` is therefore ignored by this builder instead of being preserved under the returned async logger. - 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]`. diff --git a/src-async/BitLoggerAsync_test.mbt b/src-async/BitLoggerAsync_test.mbt index 9a940b7..abeab6e 100644 --- a/src-async/BitLoggerAsync_test.mbt +++ b/src-async/BitLoggerAsync_test.mbt @@ -613,6 +613,29 @@ test "application text async logger uses text facade build path" { inspect(logger.target, content="async.app.text") } +test "application text async logger builder ignores sync queue layer" { + let logger = build_application_text_async_logger( + AsyncLoggerBuildConfig::new( + logger=@bitlogger.LoggerConfig::new( + min_level=@bitlogger.Level::Warn, + target="async.app.text.queued", + queue=Some(@bitlogger.QueueConfig::new(3, overflow=@bitlogger.QueueOverflowPolicy::DropNewest)), + sink=@bitlogger.SinkConfig::new( + kind=@bitlogger.SinkKind::TextConsole, + text_formatter=@bitlogger.TextFormatterConfig::new(show_timestamp=false, separator=" | "), + ), + ), + async_config=AsyncLoggerConfig::new(max_pending=2), + ), + ) + + inspect(logger.is_enabled(@bitlogger.Level::Error), content="true") + inspect(logger.is_enabled(@bitlogger.Level::Info), content="false") + inspect(logger.target, content="async.app.text.queued") + inspect(logger.pending_count(), content="0") + inspect(logger.dropped_count(), content="0") +} + test "build async text logger keeps text-console config fields" { let logger = build_async_text_logger( AsyncLoggerBuildConfig::new(