📝 Refine README wording

This commit is contained in:
Nanaloveyuki
2026-05-10 14:03:01 +08:00
parent d426945255
commit e436b214ed
2 changed files with 81 additions and 81 deletions
+56 -56
View File
@@ -12,22 +12,22 @@
## 📖 介绍 ## 📖 介绍
BitLogger 是一个基于 MoonBit 编写的结构化日志库 BitLogger 是一个使用 MoonBit 编写的结构化日志库
## ❇️ 特点 ## ❇️ 特点
- 🧩 核心能力清晰:先把 logging core 做稳,再继续扩展 rotation/async 等能力。 - 🧩 基础能力: 支持 level, formatter, sink, context field 和全局 logger.
- 🏗️ 结构明确:`level / record / formatter / sinks / logger / global` 拆文件,便于继续维护 - 🏗️ 结构清晰: `level / record / formatter / sinks / logger / global`文件, 便于维护.
- 🔌 可扩展支持 `fanout_sink(...)``callback_sink(...)`,方便后续桥接文件、指标或外部系统 - 🔌 可扩展: 支持 `fanout_sink(...)``callback_sink(...)`, 方便接入文件, 指标或外部系统.
- 🔀 可分流支持 `split_sink(...)` / `split_by_level(...)`可按谓词或 level 将日志路由到不同 sink - 🔀 可分流: 支持 `split_sink(...)` / `split_by_level(...)`, 可按谓词或 level 将日志路由到不同 sink.
- 🧱 可组合支持 `buffered_sink(...)``filter_sink(...)`,可以在不引入复杂 runtime 的前提下组合输出策略 - 🧱 可组合: 支持 `buffered_sink(...)``filter_sink(...)`, 可以组合不同输出策略.
- 🔎 可复用过滤提供 `target_has_prefix(...)``message_contains(...)``level_at_least(...)``field_equals(...)` 等过滤辅助函数 - 🔎 可复用过滤: 提供 `target_has_prefix(...)`, `message_contains(...)`, `level_at_least(...)`, `field_equals(...)` 等过滤辅助函数.
- 🩹 可变换 Record支持 `with_patch(...)``patch_sink(...)` 与脱敏/补字段/message 变换 helper - 🩹 可变换 Record: 支持 `with_patch(...)`, `patch_sink(...)` 以及脱敏, 补字段, message 变换 helper.
- 🧷 可绑定上下文支持 `bind(...)``fields(...)`,更方便地封装复用字段上下文。 - 🧷 可绑定上下文: 支持 `bind(...)``fields(...)`, 便于复用上下文字段.
- 📮 显式队列支持 `queued_sink(...)` / `with_queue(...)`有界积压溢出策略,作为后续 async sink 的 runtime-safe 基础。 - 📮 显式队列: 支持 `queued_sink(...)` / `with_queue(...)`, 支持有界积压溢出策略.
- 🧾 可配置文本格式支持 `text_formatter(...)``format_text(...)``text_console_sink(...)``formatted_callback_sink(...)` 模板化 `template` 输出 - 🧾 可配置文本格式: 支持 `text_formatter(...)`, `format_text(...)`, `text_console_sink(...)`, `formatted_callback_sink(...)` 模板化 `template` 输出.
- 💾 Native 文件输出支持 `file_sink(...)`基础 size rotation / backup retention显式 `reopen()` / `reopen_with_current_policy()` / `reopen_append()` / `reopen_truncate()` 与失败计数;当前仅保证 `native/llvm` backend 可用 - 💾 Native 文件输出: 支持 `file_sink(...)`, 基础 size rotation / backup retention, 显式 `reopen()` / `reopen_with_current_policy()` / `reopen_append()` / `reopen_truncate()` 与失败计数, 仅在 `native/llvm` backend 可用.
- 📦 面向 MoonBitAPI 和工程结构围绕 MoonBit 的 package / visibility / toolchain 现实约束设计。 - 📦 MoonBit 适配: API 和工程结构 MoonBit 的 package / visibility / toolchain 模型保持一致.
## 🚀 快速开始 ## 🚀 快速开始
@@ -227,9 +227,9 @@ match logger.file_runtime_state() {
## 📂 仓库结构 ## 📂 仓库结构
- `bitlogger/`MoonBit 库 package本体实现测试与 Mooncake README - `bitlogger/`: MoonBit 库 package, 包含本体实现, 测试与 Mooncake README
- `examples/basic/`最小可运行示例 - `examples/basic/`: 最小可运行示例
- `examples/async_basic/`基于 `moonbitlang/async` 的异步 logger 示例 - `examples/async_basic/`: 基于 `moonbitlang/async` 的异步 logger 示例
## 🔗 相关文档 ## 🔗 相关文档
@@ -238,49 +238,49 @@ match logger.file_runtime_state() {
## 📝 配置说明 ## 📝 配置说明
- 当前提供 JSON 配置层`parse_logger_config_text(...)``stringify_logger_config(...)``build_logger(...)` - 提供 JSON 配置层: `parse_logger_config_text(...)`, `stringify_logger_config(...)`, `build_logger(...)`
- `QueueConfig``TextFormatterConfig``SinkConfig` 可分别通过 `queue_config_to_json(...)` / `stringify_queue_config(...)``text_formatter_config_to_json(...)` / `stringify_text_formatter_config(...)``sink_config_to_json(...)` / `stringify_sink_config(...)` 单独导出 JSON - `QueueConfig`, `TextFormatterConfig`, `SinkConfig` 可分别通过 `queue_config_to_json(...)` / `stringify_queue_config(...)`, `text_formatter_config_to_json(...)` / `stringify_text_formatter_config(...)`, `sink_config_to_json(...)` / `stringify_sink_config(...)` 单独导出 JSON
- 支持字段`min_level``target``timestamp``sink.kind``sink.path``sink.append``sink.auto_flush``sink.rotation``sink.text_formatter``queue` - 支持字段: `min_level`, `target`, `timestamp`, `sink.kind`, `sink.path`, `sink.append`, `sink.auto_flush`, `sink.rotation`, `sink.text_formatter`, `queue`
- `sink.rotation` 当前支持 `max_bytes``max_backups`,提供基础 size-based rotation 和 backup retention - `sink.rotation` 支持 `max_bytes``max_backups`, 用于基础 size-based rotation 和 backup retention
- `file_sink(...)` 提供 `reopen()``reopen_with_current_policy()``reopen_append()``reopen_truncate()``open_failures()``write_failures()``flush_failures()``rotation_failures()`用于基础可观测性 - `file_sink(...)` 提供 `reopen()`, `reopen_with_current_policy()`, `reopen_append()`, `reopen_truncate()`, `open_failures()`, `write_failures()`, `flush_failures()`, `rotation_failures()`, 用于基础可观测性
- `file_sink(...)` 当前还提供 `append_mode()``reopen(append=...)` 在显式传值时会更新后续 reopen 使用的 append 策略`reopen_with_current_policy()` 把“按当前保存策略重开”变成显式动作,而 `reopen_append()` / `reopen_truncate()` 则为常见 append truncate 语义提供更直观入口 - `file_sink(...)` 提供 `append_mode()`. 显式传入 `reopen(append=...)`, 会更新后续 reopen 使用的 append 策略. `reopen_with_current_policy()` 使用当前保存策略重开文件, `reopen_append()` / `reopen_truncate()` 提供常见 append truncate 模式
- `file_sink(...)` 支持 `set_append_mode(...)`,用于显式修改后续 reopen 使用的 append 策略 - `file_sink(...)` 支持 `set_append_mode(...)`, 用于修改后续 reopen 使用的 append 策略
- `file_sink(...)` 也可直接读取 `path()``auto_flush_enabled()` 等基础 file 策略状态 - `file_sink(...)` 读取 `path()``auto_flush_enabled()` 等基础 file 策略状态
- `file_sink(...)` 提供 `rotation_enabled()``rotation_config()`,可直接查询当前 rotation 策略是否启用及其参数 - `file_sink(...)` 提供 `rotation_enabled()``rotation_config()`, 可查询 rotation 是否启用及其参数
- `file_sink(...)` 提供 `state()`可一次性读取 pathavailableappendauto_flushrotation 与各类 failure counter 快照 - `file_sink(...)` 提供 `state()`, 可一次性读取 path, available, append, auto_flush, rotation 与各类 failure counter 快照
- `file_sink(...)` 提供 `policy()``default_policy()`可分别读取当前策略与创建时默认策略 - `file_sink(...)` 提供 `policy()``default_policy()`, 可分别读取当前策略与创建时默认策略
- `file_sink(...)` 提供 `policy_matches_default()`,可显式判断当前运行期策略是否偏离默认策略 - `file_sink(...)` 提供 `policy_matches_default()`, 可判断当前运行期策略是否偏离默认策略
- `file_sink(...)` 支持 `set_policy(...)`可一次性写回 append/auto_flush/rotation 这组三元策略 - `file_sink(...)` 支持 `set_policy(...)`, 可一次性写回 append / auto_flush / rotation 三项策略
- `file_sink(...)` 提供 `reset_failure_counters()`,可在完成排障后清空 open/write/flush/rotation 失败计数 - `file_sink(...)` 提供 `reset_failure_counters()`, 可清空 open / write / flush / rotation 失败计数
- `file_sink(...)` 提供 `reset_policy()`可将 append/auto_flush/rotation 恢复到创建 sink 时的默认策略 - `file_sink(...)` 提供 `reset_policy()`, 可将 append / auto_flush / rotation 恢复到创建 sink 时的默认策略
- `file_sink(...)` 支持 `set_auto_flush(...)``set_rotation(...)``clear_rotation()`可在运行期调整基础写出策略 - `file_sink(...)` 支持 `set_auto_flush(...)`, `set_rotation(...)`, `clear_rotation()`, 可在运行期调整写出策略
- `build_logger(...)` 产出的 `ConfiguredLogger` 同样提供 `file_reopen()``file_reopen_with_current_policy()``file_reopen_append()``file_reopen_truncate()``file_flush()``file_close()``file_append_mode()``file_path()``file_auto_flush()``file_rotation_enabled()``file_rotation_config()``file_state()`以及 `file_set_append_mode(...)``file_set_auto_flush(...)``file_set_rotation(...)``file_clear_rotation()` 对应 file failure 计数访问器,便于配置式接入后继续运维控制 - `build_logger(...)` 产出的 `ConfiguredLogger` 提供 `file_reopen()`, `file_reopen_with_current_policy()`, `file_reopen_append()`, `file_reopen_truncate()`, `file_flush()`, `file_close()`, `file_append_mode()`, `file_path()`, `file_auto_flush()`, `file_rotation_enabled()`, `file_rotation_config()`, `file_state()`, 以及 `file_set_append_mode(...)`, `file_set_auto_flush(...)`, `file_set_rotation(...)`, `file_clear_rotation()` 对应 file failure 计数访问器
- `ConfiguredLogger` 提供 `file_runtime_state()`可在 file sink 外层包了 queue 时同时读取底层 file 快照、是否 queue 包装、当前 pending 与 dropped 计数 - `ConfiguredLogger` 提供 `file_runtime_state()`, 可在 file sink queue 包装时同时读取底层 file 快照, queue 状态, pending 计数与 dropped 计数
- `ConfiguredLogger` 提供 `file_policy()``file_default_policy()`可分别读取当前 file 策略与初始配置策略 - `ConfiguredLogger` 提供 `file_policy()``file_default_policy()`, 可分别读取当前 file 策略与初始配置策略
- `ConfiguredLogger` 提供 `file_policy_matches_default()`,可显式判断当前配置式 file 策略是否偏离默认值 - `ConfiguredLogger` 提供 `file_policy_matches_default()`, 可判断当前配置式 file 策略是否偏离默认值
- `ConfiguredLogger` 支持 `file_set_policy(...)`可一次性改写配置式 file sink 的当前运行期策略 - `ConfiguredLogger` 支持 `file_set_policy(...)`, 可一次性改写配置式 file sink 的当前运行期策略
- `ConfiguredLogger` 支持 `file_reset_failure_counters()`可在配置式 file sink 上统一清空失败计数 - `ConfiguredLogger` 支持 `file_reset_failure_counters()`, 可在配置式 file sink 上统一清空失败计数
- `ConfiguredLogger` 支持 `file_reset_policy()`可将配置式 file sink 的运行期策略恢复到初始配置 - `ConfiguredLogger` 支持 `file_reset_policy()`, 可将配置式 file sink 的运行期策略恢复到初始配置
- `file_sink_policy_to_json(...)``stringify_file_sink_policy(...)` 可将独立 file policy 直接导出为 JSON便于策略快照配置对比或诊断上报 - `file_sink_policy_to_json(...)`, `stringify_file_sink_policy(...)` 可将独立 file policy 直接导出为 JSON, 便于策略快照, 配置对比或诊断上报
- `file_sink_state_to_json(...)``stringify_file_sink_state(...)``runtime_file_state_to_json(...)``stringify_runtime_file_state(...)` 可直接把 file / queued-file 快照导出为 JSON便于排障或上报 - `file_sink_state_to_json(...)`, `stringify_file_sink_state(...)`, `runtime_file_state_to_json(...)`, `stringify_runtime_file_state(...)` 可直接把 file / queued-file 快照导出为 JSON, 便于排障或上报
- `sink.text_formatter.template` 当前支持固定 token`{timestamp}``{timestamp_ms}``{level}``{target}``{message}``{fields}` - `sink.text_formatter.template` 支持固定 token: `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, `{fields}`
- 当前可由配置直接组装的 sink 类型`console``json_console``text_console``file` - 可由配置直接组装的 sink 类型: `console`, `json_console`, `text_console`, `file`
- `queue` 作为显式包装层附着在最终 sink 外侧这仍然是同步 drain 模型不是 async runtime - `queue` 作为显式包装层附着在最终 sink 外侧. 这仍然是同步 drain 模型, 不是 async runtime
## 🧵 异步层 ## 🧵 异步层
- 当前已新增独立 package`bitlogger_async/` - 提供独立 package: `bitlogger_async/`
- 异步层基于 `moonbitlang/async`提供 `AsyncLogger``async_logger(...)`后台 `run()` worker 与有界 async queue - 异步层基于 `moonbitlang/async`, 提供 `AsyncLogger`, `async_logger(...)`, 后台 `run()` worker 与有界 async queue
- 当前 async API 支持 `with_context_fields(...)``with_filter(...)``with_patch(...)``with_target(...)``child(...)` - async API 支持 `with_context_fields(...)`, `with_filter(...)`, `with_patch(...)`, `with_target(...)`, `child(...)`
- 当前建议用 `shutdown()` 收口 worker;它会在默认模式下先等待队列清空再关闭 queue等待 worker 退出 - 建议使`shutdown()` 停止 worker. 默认模式下, 它会先等待队列清空, 再关闭 queue, 最后等待 worker 退出
- 当前已支持基础生命周期观测`is_closed()``is_running()``has_failed()``last_error()` - 提供基础生命周期观测: `is_closed()`, `is_running()`, `has_failed()`, `last_error()`
- 当前 async worker 支持 `max_batch` 批量消费以及 `flush=Never|Batch|Shutdown` 的基础 flush 策略 - async worker 支持 `max_batch` 批量消费, 以及 `flush=Never|Batch|Shutdown` 的基础 flush 策略
- 推荐启动方式见 [examples/async_basic/main.mbt](/E:/repo/MooLiteyukiBot/examples/async_basic/main.mbt:1) - 示例见 [examples/async_basic/main.mbt](/E:/repo/MooLiteyukiBot/examples/async_basic/main.mbt:1)
- 这层目前仅面向 `native/llvm` backend;它是独立 adapter,不会污染现有同步 core - 仅支持 `native/llvm` backend, 与同步 core 分开维护
### Async Config ### Async Config
- 当前已支持 `parse_async_logger_config_text(...)``stringify_async_logger_config(...)``parse_async_logger_build_config_text(...)` `build_async_logger(...)` - 提供 `parse_async_logger_config_text(...)`, `stringify_async_logger_config(...)`, `parse_async_logger_build_config_text(...)`, `build_async_logger(...)`
- JSON 顶层结构分为两个字段`logger``async_config` - JSON 顶层结构分为两个字段: `logger``async_config`
- `logger` 完全复用同步 `LoggerConfig` 的 schema`async_config` 当前支持 `max_pending``overflow``max_batch` `flush` - `logger` 复用同步 `LoggerConfig` 的 schema, `async_config` 支持 `max_pending`, `overflow`, `max_batch`, `flush`
- 当前推荐写法可直接参考 [examples/async_basic/main.mbt](/E:/repo/MooLiteyukiBot/examples/async_basic/main.mbt:1) - 用法可参考 [examples/async_basic/main.mbt](/E:/repo/MooLiteyukiBot/examples/async_basic/main.mbt:1)
+25 -25
View File
@@ -2,16 +2,16 @@
BitLogger is a minimal structured logger for MoonBit. BitLogger is a minimal structured logger for MoonBit.
BitLogger 是一个基于 MoonBit 的结构化日志库 BitLogger 是一个使用 MoonBit 编写的结构化日志库.
## Features / 特性 ## Features / 特性
- log levels: `Trace`, `Debug`, `Info`, `Warn`, `Error` - log levels: `Trace`, `Debug`, `Info`, `Warn`, `Error`
- 日志级别`Trace``Debug``Info``Warn``Error` - 日志级别: `Trace`, `Debug`, `Info`, `Warn`, `Error`
- structured key-value fields - structured key-value fields
- 结构化字段`field("key", "value")` - 结构化字段: `field("key", "value")`
- sink abstraction - sink abstraction
- sink 抽象与组合边界 - sink 抽象与组合接口
- default global console logger - default global console logger
- 默认全局 logger 辅助函数 - 默认全局 logger 辅助函数
- context fields via `with_context_fields(...)` - context fields via `with_context_fields(...)`
@@ -25,7 +25,7 @@ BitLogger 是一个基于 MoonBit 的结构化日志库。
- sink composition via `fanout_sink(...)` - sink composition via `fanout_sink(...)`
- `fanout_sink(...)` 支持多 sink 组合 - `fanout_sink(...)` 支持多 sink 组合
- sink routing via `split_sink(...)` and `split_by_level(...)` - sink routing via `split_sink(...)` and `split_by_level(...)`
- `split_sink(...)``split_by_level(...)` 支持按谓词或 level 将日志路由到不同 sink - `split_sink(...)`, `split_by_level(...)` 支持按谓词或 level 将日志路由到不同 sink
- custom callback sink via `callback_sink(...)` - custom callback sink via `callback_sink(...)`
- `callback_sink(...)` 支持自定义外部集成 - `callback_sink(...)` 支持自定义外部集成
- buffered sink via `buffered_sink(...)` - buffered sink via `buffered_sink(...)`
@@ -33,23 +33,23 @@ BitLogger 是一个基于 MoonBit 的结构化日志库。
- filter sink via `filter_sink(...)` - filter sink via `filter_sink(...)`
- `filter_sink(...)` 支持按 `Record` 条件筛选输出 - `filter_sink(...)` 支持按 `Record` 条件筛选输出
- reusable filter helpers such as `target_has_prefix(...)`, `message_contains(...)`, and `field_equals(...)` - reusable filter helpers such as `target_has_prefix(...)`, `message_contains(...)`, and `field_equals(...)`
- 提供 `target_has_prefix(...)``message_contains(...)``field_equals(...)` 等可复用过滤辅助函数 - 提供 `target_has_prefix(...)`, `message_contains(...)`, `field_equals(...)` 等可复用过滤辅助函数
- record patching via `with_patch(...)` and `patch_sink(...)` - record patching via `with_patch(...)` and `patch_sink(...)`
- 支持 `with_patch(...)``patch_sink(...)` 以及常见 record patch helper - 支持 `with_patch(...)`, `patch_sink(...)` 以及常见 record patch helper
- context binding via `bind(...)` and `fields(...)` - context binding via `bind(...)` and `fields(...)`
- 支持 `bind(...)``fields(...)`,更顺手地封装上下文字段 - 支持 `bind(...)`, `fields(...)`, 更方便封装上下文字段
- explicit queued delivery via `queued_sink(...)` and `with_queue(...)` - explicit queued delivery via `queued_sink(...)` and `with_queue(...)`
- 支持 `queued_sink(...)``with_queue(...)`有界积压与溢出策略 - 支持 `queued_sink(...)`, `with_queue(...)`, 有界积压与溢出策略
- configurable text formatting via `text_formatter(...)`, `format_text(...)`, `text_console_sink(...)`, and template-driven `template` output - configurable text formatting via `text_formatter(...)`, `format_text(...)`, `text_console_sink(...)`, and template-driven `template` output
- 支持 `text_formatter(...)``format_text(...)``text_console_sink(...)` 以及模板化 `template` 文本输出 - 支持 `text_formatter(...)`, `format_text(...)`, `text_console_sink(...)` 以及模板化 `template` 文本输出
- JSON config parsing via `parse_logger_config_text(...)` and `stringify_logger_config(...)` - JSON config parsing via `parse_logger_config_text(...)` and `stringify_logger_config(...)`
- 支持 `parse_logger_config_text(...)``stringify_logger_config(...)` 进行最小 JSON 配置读写 - 支持 `parse_logger_config_text(...)`, `stringify_logger_config(...)` 进行最小 JSON 配置读写
- `QueueConfig` / `TextFormatterConfig` / `SinkConfig` can also be exported independently through dedicated JSON helpers - `QueueConfig` / `TextFormatterConfig` / `SinkConfig` can also be exported independently through dedicated JSON helpers
- `QueueConfig` / `TextFormatterConfig` / `SinkConfig` 也可分别通过专用 JSON helper 单独导出 - `QueueConfig` / `TextFormatterConfig` / `SinkConfig` 也可分别通过专用 JSON helper 单独导出
- config-driven logger assembly via `build_logger(...)` - config-driven logger assembly via `build_logger(...)`
- 支持 `build_logger(...)` 将配置组装为可直接使用的 logger - 支持 `build_logger(...)` 将配置组装为可直接使用的 logger
- native-only file output via `file_sink(...)`, with basic size rotation, backup retention, explicit `reopen()` / `reopen_with_current_policy()` / `reopen_append()` / `reopen_truncate()`, and failure counters - native-only file output via `file_sink(...)`, with basic size rotation, backup retention, explicit `reopen()` / `reopen_with_current_policy()` / `reopen_append()` / `reopen_truncate()`, and failure counters
- 支持 `file_sink(...)`基础 size rotation / backup retention显式 `reopen()` / `reopen_with_current_policy()` / `reopen_append()` / `reopen_truncate()` 与失败计数,但当前仅保证 `native/llvm` backend 可用 - 支持 `file_sink(...)`, 基础 size rotation / backup retention, 显式 `reopen()` / `reopen_with_current_policy()` / `reopen_append()` / `reopen_truncate()` 与失败计数, 仅在 `native/llvm` backend 可用
## Example / 示例 ## Example / 示例
@@ -201,7 +201,7 @@ test {
- supported tokens / 支持的 token: `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, `{fields}` - supported tokens / 支持的 token: `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, `{fields}`
- disabled or missing parts render as empty text / 被关闭或缺失的部分会渲染为空字符串 - disabled or missing parts render as empty text / 被关闭或缺失的部分会渲染为空字符串
- `template` is intentionally a simple token replacement layer, not a full DSL / `template` 当前刻意保持为轻量 token 替换层,而不是完整 DSL - `template` is intentionally a simple token replacement layer, not a full DSL / `template` 使用轻量 token 替换方式, 不是完整 DSL
```mbt check ```mbt check
test { test {
@@ -235,29 +235,29 @@ test {
## File Rotation / 文件轮转 ## File Rotation / 文件轮转
- basic rotation is size-based / 当前基础轮转按文件大小触发 - basic rotation is size-based / 基础轮转按文件大小触发
- `file_rotation(max_bytes, max_backups=...)` controls threshold and retained backups / `file_rotation(max_bytes, max_backups=...)` 控制触发阈值和保留备份数 - `file_rotation(max_bytes, max_backups=...)` controls threshold and retained backups / `file_rotation(max_bytes, max_backups=...)` 控制触发阈值和保留备份数
- JSON config uses `sink.rotation.max_bytes` and `sink.rotation.max_backups` / JSON 配置使用 `sink.rotation.max_bytes` 与 `sink.rotation.max_backups` - JSON config uses `sink.rotation.max_bytes` and `sink.rotation.max_backups` / JSON 配置使用 `sink.rotation.max_bytes` 与 `sink.rotation.max_backups`
- `FileSink::reopen()` can explicitly reopen the current file handle, `FileSink::reopen_with_current_policy()` makes the stored-policy reopen path explicit, and `FileSink::reopen_append()` / `FileSink::reopen_truncate()` cover the two common reopen modes directly / `FileSink::reopen()` 可显式重开当前文件句柄`FileSink::reopen_with_current_policy()` 把“按当前保存策略重开”变成显式动作,`FileSink::reopen_append()` / `FileSink::reopen_truncate()` 则直接覆盖常见 append 与 truncate 模式 - `FileSink::reopen()` can explicitly reopen the current file handle, `FileSink::reopen_with_current_policy()` makes the stored-policy reopen path explicit, and `FileSink::reopen_append()` / `FileSink::reopen_truncate()` cover the two common reopen modes directly / `FileSink::reopen()` 可显式重开当前文件句柄, `FileSink::reopen_with_current_policy()` 按当前保存策略重开文件, `FileSink::reopen_append()` / `FileSink::reopen_truncate()` 提供常见 append 与 truncate 模式
- `append_mode()` exposes the current append policy, and `reopen(append=...)` updates that policy for later reopen calls / `append_mode()` 可读取当前 append 策略`reopen(append=...)` 会更新后续 reopen 复用的 append 策略 - `append_mode()` exposes the current append policy, and `reopen(append=...)` updates that policy for later reopen calls / `append_mode()` 可读取当前 append 策略, `reopen(append=...)` 会更新后续 reopen 复用的 append 策略
- `set_append_mode(...)` updates the stored append policy without forcing an immediate reopen / `set_append_mode(...)` 可直接更新保存的 append 策略,但不会强制立即 reopen - `set_append_mode(...)` updates the stored append policy without forcing an immediate reopen / `set_append_mode(...)` 可直接更新保存的 append 策略, 不会强制立即 reopen
- `path()` and `auto_flush_enabled()` expose core file sink policy state / `path()` 与 `auto_flush_enabled()` 可读取 file sink 的基础策略状态 - `path()` and `auto_flush_enabled()` expose core file sink policy state / `path()` 与 `auto_flush_enabled()` 可读取 file sink 的基础策略状态
- `rotation_enabled()` and `rotation_config()` expose whether rotation is active and which settings are currently applied / `rotation_enabled()` 与 `rotation_config()` 可读取 rotation 是否启用及当前配置参数 - `rotation_enabled()` and `rotation_config()` expose whether rotation is active and which settings are currently applied / `rotation_enabled()` 与 `rotation_config()` 可读取 rotation 是否启用及当前配置参数
- `state()` exposes a single file-sink snapshot including path, availability, append policy, auto-flush, rotation config, and failure counters / `state()` 可一次性读取包含 pathavailabilityappendauto-flushrotation 配置与失败计数的 file sink 快照 - `state()` exposes a single file-sink snapshot including path, availability, append policy, auto-flush, rotation config, and failure counters / `state()` 可一次性读取包含 path, availability, append, auto_flush, rotation 配置与失败计数的 file sink 快照
- `policy()` and `default_policy()` expose the current runtime policy and the sink's original defaults separately / `policy()` 与 `default_policy()` 可分别读取当前运行期策略与 sink 初始默认策略 - `policy()` and `default_policy()` expose the current runtime policy and the sink's original defaults separately / `policy()` 与 `default_policy()` 可分别读取当前运行期策略与 sink 初始默认策略
- `policy_matches_default()` explicitly tells whether the current runtime policy has drifted from the defaults / `policy_matches_default()` 可显式判断当前运行期策略是否已偏离默认策略 - `policy_matches_default()` explicitly tells whether the current runtime policy has drifted from the defaults / `policy_matches_default()` 可显式判断当前运行期策略是否已偏离默认策略
- `set_policy(...)` applies append, auto-flush, and rotation as a bundled runtime update / `set_policy(...)` 可将 appendauto-flushrotation 作为一组运行期策略一次性写回 - `set_policy(...)` applies append, auto-flush, and rotation as a bundled runtime update / `set_policy(...)` 可将 append, auto_flush, rotation 作为一组运行期策略一次性写回
- `reset_failure_counters()` clears the open/write/flush/rotation counters after diagnostics or recovery / `reset_failure_counters()` 可在排障或恢复后清空 open/write/flush/rotation 失败计数 - `reset_failure_counters()` clears the open/write/flush/rotation counters after diagnostics or recovery / `reset_failure_counters()` 可在排障或恢复后清空 open/write/flush/rotation 失败计数
- `reset_policy()` restores append, auto-flush, and rotation back to the sink's original defaults / `reset_policy()` 可将 appendauto-flushrotation 恢复到 sink 初始默认策略 - `reset_policy()` restores append, auto-flush, and rotation back to the sink's original defaults / `reset_policy()` 可将 append, auto_flush, rotation 恢复到 sink 初始默认策略
- `file_sink_policy_to_json(...)` / `stringify_file_sink_policy(...)` also export standalone file policy snapshots as JSON / `file_sink_policy_to_json(...)` / `stringify_file_sink_policy(...)` 也可将独立 file policy 快照直接导出为 JSON - `file_sink_policy_to_json(...)` / `stringify_file_sink_policy(...)` also export standalone file policy snapshots as JSON / `file_sink_policy_to_json(...)` / `stringify_file_sink_policy(...)` 也可将独立 file policy 快照直接导出为 JSON
- `file_sink_state_to_json(...)` / `stringify_file_sink_state(...)` and `runtime_file_state_to_json(...)` / `stringify_runtime_file_state(...)` export snapshots as JSON / `file_sink_state_to_json(...)` / `stringify_file_sink_state(...)` 与 `runtime_file_state_to_json(...)` / `stringify_runtime_file_state(...)` 可将快照直接导出为 JSON - `file_sink_state_to_json(...)` / `stringify_file_sink_state(...)` and `runtime_file_state_to_json(...)` / `stringify_runtime_file_state(...)` export snapshots as JSON / `file_sink_state_to_json(...)` / `stringify_file_sink_state(...)` 与 `runtime_file_state_to_json(...)` / `stringify_runtime_file_state(...)` 可将快照直接导出为 JSON
- `set_auto_flush(...)`, `set_rotation(...)`, and `clear_rotation()` allow runtime tuning of core file sink policies / `set_auto_flush(...)``set_rotation(...)``clear_rotation()` 可在运行期调整 file sink 的基础策略 - `set_auto_flush(...)`, `set_rotation(...)`, and `clear_rotation()` allow runtime tuning of core file sink policies / `set_auto_flush(...)`, `set_rotation(...)`, `clear_rotation()` 可在运行期调整 file sink 的基础策略
- `open_failures()``write_failures()``flush_failures()``rotation_failures()` expose basic sink health counters / `open_failures()``write_failures()``flush_failures()``rotation_failures()` 可用于观察基础 sink 健康状态 - `open_failures()`, `write_failures()`, `flush_failures()`, `rotation_failures()` expose basic sink health counters / `open_failures()`, `write_failures()`, `flush_failures()`, `rotation_failures()` 可用于观察基础 sink 健康状态
- `ConfiguredLogger` also forwards file reopen, flush, close, append-mode, path, auto-flush, rotation-config, state snapshot, append setter, policy setter, and failure-counter helpers for config-built file sinks / `ConfiguredLogger` 也会为配置生成的 file sink 转发 reopenflushcloseappend-modepathauto-flushrotation 配置state 快照append setter策略 setter 与失败计数访问器 - `ConfiguredLogger` also forwards file reopen, flush, close, append-mode, path, auto-flush, rotation-config, state snapshot, append setter, policy setter, and failure-counter helpers for config-built file sinks / `ConfiguredLogger` 也会为配置生成的 file sink 转发 reopen, flush, close, append-mode, path, auto-flush, rotation 配置, state 快照, append setter, 策略 setter 与失败计数访问器
- `ConfiguredLogger::file_runtime_state()` also reports whether a file sink is queue-wrapped and exposes the outer queue pending/drop counters together with the inner file snapshot / `ConfiguredLogger::file_runtime_state()` 还可报告 file sink 是否被 queue 包装并将外层 queue 的 pending/drop 计数与内层 file 快照一起返回 - `ConfiguredLogger::file_runtime_state()` also reports whether a file sink is queue-wrapped and exposes the outer queue pending/drop counters together with the inner file snapshot / `ConfiguredLogger::file_runtime_state()` 还可报告 file sink 是否被 queue 包装, 并将外层 queue 的 pending/drop 计数与内层 file 快照一起返回
- `ConfiguredLogger::file_policy()` and `ConfiguredLogger::file_default_policy()` also expose current runtime policy and initial config policy separately / `ConfiguredLogger::file_policy()` 与 `ConfiguredLogger::file_default_policy()` 也可分别读取当前运行期策略与初始配置策略 - `ConfiguredLogger::file_policy()` and `ConfiguredLogger::file_default_policy()` also expose current runtime policy and initial config policy separately / `ConfiguredLogger::file_policy()` 与 `ConfiguredLogger::file_default_policy()` 也可分别读取当前运行期策略与初始配置策略
- `ConfiguredLogger::file_policy_matches_default()` also tells whether the current runtime file policy has drifted from the default config / `ConfiguredLogger::file_policy_matches_default()` 也可显式判断当前运行期 file 策略是否已偏离默认配置 - `ConfiguredLogger::file_policy_matches_default()` also tells whether the current runtime file policy has drifted from the default config / `ConfiguredLogger::file_policy_matches_default()` 也可显式判断当前运行期 file 策略是否已偏离默认配置
- `ConfiguredLogger::file_set_policy()` also applies a bundled runtime file policy through the config-built control surface / `ConfiguredLogger::file_set_policy()` 也可通过配置式控制面一次性写回 bundled file 策略 - `ConfiguredLogger::file_set_policy()` also applies a bundled runtime file policy through the config-built control surface / `ConfiguredLogger::file_set_policy()` 也可通过配置式控制面一次性写回 bundled file 策略
- `ConfiguredLogger::file_reset_failure_counters()` also clears file failure counters through the config-built control surface / `ConfiguredLogger::file_reset_failure_counters()` 也可通过配置式控制面清空 file 失败计数 - `ConfiguredLogger::file_reset_failure_counters()` also clears file failure counters through the config-built control surface / `ConfiguredLogger::file_reset_failure_counters()` 也可通过配置式控制面清空 file 失败计数
- `ConfiguredLogger::file_reset_policy()` also restores runtime file policy back to the initial config values / `ConfiguredLogger::file_reset_policy()` 也可将运行期 file 策略恢复到初始配置值 - `ConfiguredLogger::file_reset_policy()` also restores runtime file policy back to the initial config values / `ConfiguredLogger::file_reset_policy()` 也可将运行期 file 策略恢复到初始配置值
- current scope is observability-first, not a full self-healing sink runtime / 当前定位仍以可观测性优先,不是完整自愈型 sink runtime - current scope is observability-first, not a full self-healing sink runtime / 当前以可观测性为主, 不提供完整的自恢复 sink runtime.