mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-08-02 08:24:42 +00:00
✅ cover app text async composition
This commit is contained in:
@@ -2214,6 +2214,47 @@ async test "application text async logger keeps async helper surface" {
|
|||||||
inspect(logger.last_error(), content="")
|
inspect(logger.last_error(), content="")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async test "application text async logger keeps broader async composition surface" {
|
||||||
|
let logger : ApplicationTextAsyncLogger = build_application_text_async_logger(
|
||||||
|
AsyncLoggerBuildConfig::new(
|
||||||
|
logger=@bitlogger.text_console(
|
||||||
|
min_level=@bitlogger.Level::Warn,
|
||||||
|
target="async.app.text.compose",
|
||||||
|
text_formatter=@bitlogger.TextFormatterConfig::new(show_timestamp=false, separator=" | "),
|
||||||
|
),
|
||||||
|
async_config=AsyncLoggerConfig::new(
|
||||||
|
max_pending=2,
|
||||||
|
overflow=AsyncOverflowPolicy::DropNewest,
|
||||||
|
flush=AsyncFlushPolicy::Shutdown,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.with_timestamp()
|
||||||
|
.with_context_fields([@bitlogger.field("service", "bitlogger")])
|
||||||
|
.child("worker")
|
||||||
|
|
||||||
|
inspect(logger.target, content="async.app.text.compose.worker")
|
||||||
|
inspect(logger.timestamp, content="true")
|
||||||
|
inspect(logger.is_enabled(@bitlogger.Level::Error), content="true")
|
||||||
|
inspect(logger.is_enabled(@bitlogger.Level::Info), content="false")
|
||||||
|
|
||||||
|
logger.error("one")
|
||||||
|
logger.error("two")
|
||||||
|
inspect(logger.pending_count(), content="2")
|
||||||
|
inspect(logger.dropped_count(), content="0")
|
||||||
|
|
||||||
|
@async.with_task_group(group => {
|
||||||
|
group.spawn_bg(() => logger.run())
|
||||||
|
logger.shutdown()
|
||||||
|
})
|
||||||
|
|
||||||
|
inspect(logger.is_closed(), content="true")
|
||||||
|
inspect(logger.pending_count(), content="0")
|
||||||
|
inspect(logger.dropped_count(), content="0")
|
||||||
|
inspect(logger.has_failed(), content="false")
|
||||||
|
inspect(logger.last_error(), content="")
|
||||||
|
}
|
||||||
|
|
||||||
test "application text async logger builder ignores sync queue layer" {
|
test "application text async logger builder ignores sync queue layer" {
|
||||||
let logger = build_application_text_async_logger(
|
let logger = build_application_text_async_logger(
|
||||||
AsyncLoggerBuildConfig::new(
|
AsyncLoggerBuildConfig::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user