Add split sink routing helpers

This commit is contained in:
Nanaloveyuki
2026-05-09 22:00:02 +08:00
parent fa2a165942
commit 2e008b649c
7 changed files with 159 additions and 0 deletions
+14
View File
@@ -17,6 +17,20 @@ fn main {
)
fanout_logger.info("dual output", fields=[@lib.field("kind", "fanout")])
let split_logger = @lib.Logger::new(
@lib.split_by_level(
@lib.callback_sink(fn(rec) {
println("high priority: \{rec.level.label()} \{rec.message}")
}),
@lib.console_sink(),
min_level=@lib.Level::Warn,
),
min_level=@lib.Level::Trace,
target="split",
)
split_logger.info("normal output")
split_logger.warn("warning output")
let timed_logger = @lib.Logger::new(@lib.console_sink(), min_level=@lib.Level::Info, target="timed")
.with_timestamp()
timed_logger.info("timestamp enabled", fields=[@lib.field("kind", "time")])