mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
📝 Document config-driven logger usage and 0.3 changes
This commit is contained in:
@@ -38,6 +38,10 @@ BitLogger 是一个基于 MoonBit 的结构化日志库。
|
||||
- 支持 `queued_sink(...)`、`with_queue(...)`、有界积压与溢出策略
|
||||
- configurable text formatting via `text_formatter(...)`, `format_text(...)`, and `text_console_sink(...)`
|
||||
- 支持 `text_formatter(...)`、`format_text(...)`、`text_console_sink(...)` 等文本格式化能力
|
||||
- JSON config parsing via `parse_logger_config_text(...)` and `stringify_logger_config(...)`
|
||||
- 支持 `parse_logger_config_text(...)`、`stringify_logger_config(...)` 进行最小 JSON 配置读写
|
||||
- config-driven logger assembly via `build_logger(...)`
|
||||
- 支持 `build_logger(...)` 将配置组装为可直接使用的 logger
|
||||
- native-only file output via `file_sink(...)`
|
||||
- 支持 `file_sink(...)`,但当前仅保证 `native/llvm` backend 可用
|
||||
|
||||
@@ -146,6 +150,17 @@ test {
|
||||
}
|
||||
```
|
||||
|
||||
```mbt check
|
||||
test {
|
||||
let config = parse_logger_config_text(
|
||||
"{\"min_level\":\"debug\",\"target\":\"config.demo\",\"timestamp\":true,\"sink\":{\"kind\":\"text_console\",\"text_formatter\":{\"separator\":\" | \",\"show_timestamp\":false}},\"queue\":{\"max_pending\":2,\"overflow\":\"DropOldest\"}}",
|
||||
)
|
||||
let logger = build_logger(config)
|
||||
logger.info("configured from json")
|
||||
ignore(logger.flush())
|
||||
}
|
||||
```
|
||||
|
||||
```mbt check
|
||||
test {
|
||||
if native_files_supported() {
|
||||
|
||||
Reference in New Issue
Block a user