🩹 Fix the major version must be 0
BitLogger 是一个使用 MoonBit 编写的结构化日志库,适合命令行工具、服务和需要统一日志输出的项目。
BitLogger 提供统一的日志级别、目标名、结构化字段和可定制格式,既可以直接输出到控制台,也可以在 native 环境写入文件,并提供异步日志版本。
let logger = build_logger( text_console( min_level=Level::Info, target="demo", text_formatter=TextFormatterConfig::new(show_timestamp=false, separator=" | "), ), ) logger.info("starting", fields=[field("port", "8080")]) ignore(logger.flush())
推荐从 console(...)、json_console(...)、text_console(...)、file(...) 这几个入口开始,再按需配合 with_queue(...) 或 with_file_rotation(...)。
console(...)
json_console(...)
text_console(...)
file(...)
with_queue(...)
with_file_rotation(...)
如果你需要自己组合 sink,比如 fanout、split、callback,再使用 Logger::new(...)。
fanout
split
callback
Logger::new(...)
BitLogger
native
js
wasm-gc
bitlogger_async
wasm
moon.pkg
llvm
native_files_supported()
src-async
examples/async_basic
build_logger(...)
build_async_logger(...)
examples/console_basic/
examples/text_formatter/
examples/style_tags/
examples/config_build/
examples/presets/
examples/file_rotation/
examples/async_basic/
常用入口:text_console(...)、file(...)、with_queue(...)、build_logger(...)、build_async_logger(...)
A Simple Logger base on MoonBit.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
BitLogger
BitLogger 是一个使用 MoonBit 编写的结构化日志库,适合命令行工具、服务和需要统一日志输出的项目。
介绍
BitLogger 提供统一的日志级别、目标名、结构化字段和可定制格式,既可以直接输出到控制台,也可以在 native 环境写入文件,并提供异步日志版本。
快速开始
推荐从
console(...)、json_console(...)、text_console(...)、file(...)这几个入口开始,再按需配合with_queue(...)或with_file_rotation(...)。如果你需要自己组合 sink,比如
fanout、split、callback,再使用Logger::new(...)。支持情况
BitLogger当前在 CI 中检查/验证的目标是native、js、wasm-gcbitlogger_async当前在 CI 中检查native、js、wasm-gc,测试覆盖native、js、wasm-gcwasm目标在源码moon.pkg中保留声明,但当前未纳入 CI 验证口径llvm目前按实验性目标处理,当前环境未完成验证native_files_supported()src-async可用,但示例examples/async_basic目前仍按 native 入口提供主要能力
build_logger(...)、build_async_logger(...)src-asyncpackage示例
examples/console_basic/:最小 console / json console 示例examples/text_formatter/:文本格式与模板示例examples/style_tags/:style tag 与彩色输出示例examples/config_build/:配置构建示例examples/presets/:常用预设组合示例examples/file_rotation/:文件输出与轮转示例,仅适用于 nativeexamples/async_basic/:异步日志示例文档
常用入口:
text_console(...)、file(...)、with_queue(...)、build_logger(...)、build_async_logger(...)