From e38b0b4150a237e4a0f039c3f31f7f7e36188c00 Mon Sep 17 00:00:00 2001 From: Nanaloveyuki Date: Sun, 14 Jun 2026 02:22:49 +0800 Subject: [PATCH] :white_check_mark: cover application async builder queue path --- docs/api/build-application-async-logger.md | 1 + ...arse-and-build-application-async-logger.md | 1 + src-async/BitLoggerAsync_test.mbt | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/docs/api/build-application-async-logger.md b/docs/api/build-application-async-logger.md index a974e03..2328ccc 100644 --- a/docs/api/build-application-async-logger.md +++ b/docs/api/build-application-async-logger.md @@ -38,6 +38,7 @@ Detailed rules explaining key parameters and behaviors - This API delegates to `build_async_logger(...)` directly. - That means the embedded `LoggerConfig` is built first through the normal synchronous config path before the outer async layer is applied. - Any optional synchronous queue layer and runtime-sink controls chosen by `build_logger(config.logger)` remain active under the returned logger. +- In particular, a sync queue configured on `LoggerConfig.queue` is preserved inside the wrapped `RuntimeSink` variant instead of being stripped away by the application alias. - Because the result is only the `ApplicationAsyncLogger` alias over `AsyncLogger[@bitlogger.RuntimeSink]`, 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()`, and `last_error()`. - It also keeps the same failure/reset and runtime-dependent post-close behavior documented on the underlying runtime-sink async logger. diff --git a/docs/api/parse-and-build-application-async-logger.md b/docs/api/parse-and-build-application-async-logger.md index 7ee8fb7..558a3d5 100644 --- a/docs/api/parse-and-build-application-async-logger.md +++ b/docs/api/parse-and-build-application-async-logger.md @@ -39,6 +39,7 @@ Detailed rules explaining key parameters and behaviors - Both the embedded sync logger config and async queue/runtime config are validated by the parser layer. - The embedded `LoggerConfig` is then built through the normal synchronous config path before the outer async layer is applied. - Any optional synchronous queue layer and runtime-sink controls from the parsed `logger` section remain active under the returned async logger. +- That includes preserving a parsed sync queue configuration inside the resulting `RuntimeSink` variant rather than collapsing it away during application-alias construction. - Because the result is the `ApplicationAsyncLogger` alias over `AsyncLogger[@bitlogger.RuntimeSink]`, this parse-and-build path returns the same underlying async logger value that `parse_async_logger_build_config_text(...)` plus `build_async_logger(...)` would produce, without narrowing the helper surface. - The returned logger keeps the full async lifecycle and state helpers directly. - Use `parse_and_build_library_async_logger(...)` instead when the same parsed runtime-sink result should be wrapped and narrowed for a library boundary. diff --git a/src-async/BitLoggerAsync_test.mbt b/src-async/BitLoggerAsync_test.mbt index a78d04c..9a940b7 100644 --- a/src-async/BitLoggerAsync_test.mbt +++ b/src-async/BitLoggerAsync_test.mbt @@ -571,6 +571,32 @@ test "application async logger aliases runtime async entry" { inspect(logger.target, content="async.app") } +test "application async logger builder preserves sync queue-backed runtime sink" { + let logger = build_application_async_logger( + AsyncLoggerBuildConfig::new( + logger=@bitlogger.LoggerConfig::new( + min_level=@bitlogger.Level::Warn, + target="async.app.queued", + queue=Some(@bitlogger.QueueConfig::new(3, overflow=@bitlogger.QueueOverflowPolicy::DropNewest)), + ), + 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.queued") + inspect(logger.sink.pending_count(), content="0") + inspect(logger.sink.dropped_count(), content="0") + inspect(match logger.sink { + @bitlogger.RuntimeSink::QueuedConsole(_) => "QueuedConsole" + @bitlogger.RuntimeSink::QueuedJsonConsole(_) => "QueuedJsonConsole" + @bitlogger.RuntimeSink::QueuedTextConsole(_) => "QueuedTextConsole" + @bitlogger.RuntimeSink::QueuedFile(_) => "QueuedFile" + _ => "Other" + }, content="QueuedConsole") +} + test "application text async logger uses text facade build path" { let logger = build_application_text_async_logger( AsyncLoggerBuildConfig::new(