mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-31 23:44:39 +00:00
✅ cover library text async builder path
This commit is contained in:
@@ -39,6 +39,7 @@ Detailed rules explaining key parameters and behaviors
|
|||||||
- It always produces a concrete `FormattedConsoleSink` from `config.logger.sink.text_formatter` instead of branching on sink kinds.
|
- It always produces a concrete `FormattedConsoleSink` from `config.logger.sink.text_formatter` instead of branching on sink kinds.
|
||||||
- Unlike `build_library_async_logger(...)`, this facade does not go through the full synchronous configured-logger build path first.
|
- 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 `LoggerConfig` fields directly and therefore does not apply `LoggerConfig.queue` or preserve sync runtime sink controls.
|
- 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 behind the wrapped text-console async logger.
|
||||||
- The returned facade wraps the same underlying `AsyncLogger[@bitlogger.FormattedConsoleSink]` value that `build_async_text_logger(...)` would return directly, so `run()`, `shutdown()`, failure/reset handling, and runtime-dependent close behavior are unchanged under the narrower public type.
|
- The returned facade wraps the same underlying `AsyncLogger[@bitlogger.FormattedConsoleSink]` value that `build_async_text_logger(...)` would return directly, so `run()`, `shutdown()`, failure/reset handling, and runtime-dependent close behavior are unchanged under the narrower public type.
|
||||||
- Async state helpers such as `pending_count()`, `dropped_count()`, `state()`, `wait_idle()`, and failure-status inspection remain on the underlying `AsyncLogger[@bitlogger.FormattedConsoleSink]`, not on the returned facade itself.
|
- Async state helpers such as `pending_count()`, `dropped_count()`, `state()`, `wait_idle()`, and failure-status inspection remain on the underlying `AsyncLogger[@bitlogger.FormattedConsoleSink]`, not on the returned facade itself.
|
||||||
- `to_async_logger()` can recover the underlying full async logger if needed.
|
- `to_async_logger()` can recover the underlying full async logger if needed.
|
||||||
|
|||||||
@@ -547,6 +547,30 @@ test "library async text logger can be built from typed config" {
|
|||||||
inspect(full.target, content="async.lib.text")
|
inspect(full.target, content="async.lib.text")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "library async text logger builder ignores sync queue layer" {
|
||||||
|
let logger = build_library_async_text_logger(
|
||||||
|
AsyncLoggerBuildConfig::new(
|
||||||
|
logger=@bitlogger.LoggerConfig::new(
|
||||||
|
min_level=@bitlogger.Level::Warn,
|
||||||
|
target="async.lib.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),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
let full = logger.to_async_logger()
|
||||||
|
|
||||||
|
inspect(logger.is_enabled(@bitlogger.Level::Error), content="true")
|
||||||
|
inspect(logger.is_enabled(@bitlogger.Level::Info), content="false")
|
||||||
|
inspect(full.target, content="async.lib.text.queued")
|
||||||
|
inspect(full.pending_count(), content="0")
|
||||||
|
inspect(full.dropped_count(), content="0")
|
||||||
|
}
|
||||||
|
|
||||||
async test "async logger can project to library async logger" {
|
async test "async logger can project to library async logger" {
|
||||||
let logger = build_async_logger(
|
let logger = build_async_logger(
|
||||||
AsyncLoggerBuildConfig::new(
|
AsyncLoggerBuildConfig::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user