mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-29 14:06:34 +00:00
📝 align portable examples and release messaging
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user