📝 align portable examples and release messaging

This commit is contained in:
Nanaloveyuki
2026-05-21 14:12:56 +08:00
parent d4f83f5ccb
commit 3e8d4c50a9
9 changed files with 135 additions and 74 deletions
+19 -10
View File
@@ -1,19 +1,28 @@
fn main {
if !@lib.native_files_supported() {
println("native file sink is not available on this backend")
println("native file sink is not available on this backend; examples/presets stays portable, while file_rotation remains native-focused")
return
}
let logger = @lib.Logger::new(
@lib.file_sink(
"bitlogger-example.log",
auto_flush=true,
rotation=Some(@lib.file_rotation(128, max_backups=2)),
let logger = @lib.build_logger(
@lib.with_file_rotation(
@lib.file(
"bitlogger-example.log",
min_level=@lib.Level::Info,
target="demo.file",
auto_flush=true,
) catch {
err => {
ignore(err)
println("invalid file preset config")
return
}
},
128,
max_backups=2,
),
min_level=@lib.Level::Info,
target="demo.file",
)
logger.info("file rotation ready", fields=[@lib.field("kind", "file")])
ignore(logger.sink.flush())
ignore(logger.sink.close())
ignore(logger.flush())
ignore(logger.file_close())
}