📝 refresh runtime file export docs

This commit is contained in:
Nanaloveyuki
2026-06-13 23:37:55 +08:00
parent 06541a578c
commit 56ba583680
6 changed files with 19 additions and 14 deletions
+4 -3
View File
@@ -37,6 +37,7 @@ Detailed rules explaining key parameters and behaviors
- `rotation` is exported as `null` when rotation is disabled.
- This helper exports runtime file policy, not current file health counters or availability.
- The JSON value is useful for policy snapshots, comparisons, and diagnostics payloads.
- Typical inputs come from `FileSink::policy()`, `RuntimeSink::file_policy()`, or `ConfiguredLogger::file_policy()`.
### How to Use
@@ -44,9 +45,9 @@ Here are some specific examples provided.
#### When Need Structured Policy Snapshots
When file sink policy should be embedded into a larger JSON payload:
When file policy should be embedded into a larger JSON payload:
```moonbit
let value = file_sink_policy_to_json(sink.policy())
let value = file_sink_policy_to_json(runtime.file_policy())
```
In this example, the runtime file policy becomes a reusable structured value.
@@ -71,4 +72,4 @@ e.g.:
1. Use this helper when downstream code expects `JsonValue` rather than text.
2. It pairs naturally with `policy()` and `default_policy()` runtime accessors.
2. It pairs naturally with `FileSink::policy()`, `RuntimeSink::file_policy()`, and related default-policy accessors.
+4 -3
View File
@@ -37,6 +37,7 @@ Detailed rules explaining key parameters and behaviors
- `rotation` is exported as `null` when rotation is disabled.
- This helper exports state snapshots, not mutable runtime control handles.
- It is useful when file sink state should be embedded into larger diagnostics payloads.
- Typical inputs come from `FileSink::state()`, `RuntimeSink::file_state()`, or `ConfiguredLogger::file_state()`.
### How to Use
@@ -44,9 +45,9 @@ Here are some specific examples provided.
#### When Need Structured File Diagnostics
When file sink status should be composed into a larger JSON object:
When file runtime status should be composed into a larger JSON object:
```moonbit
let value = file_sink_state_to_json(sink.state())
let value = file_sink_state_to_json(runtime.file_state())
```
In this example, callers receive a structured file-state snapshot instead of plain text.
@@ -71,4 +72,4 @@ e.g.:
1. Use this helper when diagnostics consumers expect `JsonValue`.
2. It pairs naturally with `FileSink::state()` and `ConfiguredLogger::file_state()`.
2. It pairs naturally with `FileSink::state()`, `RuntimeSink::file_state()`, and `ConfiguredLogger::file_state()`.
+3 -3
View File
@@ -13,7 +13,7 @@ key-word:
## Runtime-file-state-to-json
Convert `RuntimeFileState` into a `JsonValue`. This helper exports both file sink status and outer queue metrics for queued file runtime diagnostics.
Convert `RuntimeFileState` into a `JsonValue`. This helper exports both file sink status and queue metrics for combined runtime file diagnostics.
### Interface
@@ -36,7 +36,7 @@ Detailed rules explaining key parameters and behaviors
- The output includes `file`, `queued`, `pending_count`, and `dropped_count`.
- `file` is itself exported as a nested file sink state object.
- This helper is richer than `file_sink_state_to_json(...)` because it also carries queue wrapping context.
- It is useful for `ConfiguredLogger::file_runtime_state()` and similar queued-file diagnostics flows.
- It is useful for `RuntimeSink::file_runtime_state()`, `ConfiguredLogger::file_runtime_state()`, and similar queued-file diagnostics flows.
### How to Use
@@ -71,4 +71,4 @@ e.g.:
1. Use this helper when file and queue runtime context should stay together.
2. It is especially useful for configured queued file loggers.
2. It is especially useful for queued file runtime paths, whether accessed directly or through configured loggers.
+3 -2
View File
@@ -38,6 +38,7 @@ Detailed rules explaining key parameters and behaviors
- `pretty=true` returns indented JSON for human inspection.
- This helper builds on top of `file_sink_policy_to_json(...)`.
- The output is suited for support dumps, policy snapshots, and generated diagnostics text.
- Typical inputs come from `FileSink::policy()`, `RuntimeSink::file_policy()`, or `ConfiguredLogger::file_policy()`.
### How to Use
@@ -47,7 +48,7 @@ Here are some specific examples provided.
When current file policy should be printed for diagnostics:
```moonbit
println(stringify_file_sink_policy(sink.policy(), pretty=true))
println(stringify_file_sink_policy(runtime.file_policy(), pretty=true))
```
In this example, the runtime file policy is rendered in readable JSON.
@@ -56,7 +57,7 @@ In this example, the runtime file policy is rendered in readable JSON.
When a file policy snapshot should stay small:
```moonbit
let text = stringify_file_sink_policy(sink.policy())
let text = stringify_file_sink_policy(runtime.file_policy())
```
In this example, compact JSON is produced without extra formatting logic.
+4 -3
View File
@@ -38,6 +38,7 @@ Detailed rules explaining key parameters and behaviors
- `pretty=true` returns indented JSON for human diagnostics.
- This helper builds on top of `file_sink_state_to_json(...)`.
- The output is well-suited for support dumps, incident reports, and log snapshots.
- Typical inputs come from `FileSink::state()`, `RuntimeSink::file_state()`, or `ConfiguredLogger::file_state()`.
### How to Use
@@ -45,9 +46,9 @@ Here are some specific examples provided.
#### When Need Human-readable File Diagnostics
When file sink status should be printed for operators:
When file runtime status should be printed for operators:
```moonbit
println(stringify_file_sink_state(sink.state(), pretty=true))
println(stringify_file_sink_state(runtime.file_state(), pretty=true))
```
In this example, the full file-state snapshot is rendered in readable JSON.
@@ -56,7 +57,7 @@ In this example, the full file-state snapshot is rendered in readable JSON.
When a snapshot should stay small:
```moonbit
let text = stringify_file_sink_state(sink.state())
let text = stringify_file_sink_state(runtime.file_state())
```
In this example, compact JSON is returned without extra formatting logic.
+1
View File
@@ -38,6 +38,7 @@ Detailed rules explaining key parameters and behaviors
- `pretty=true` returns indented JSON for human diagnostics.
- This helper builds on top of `runtime_file_state_to_json(...)`.
- The output is useful when queued file runtime state should be printed directly during support or incident handling.
- Typical inputs come from `RuntimeSink::file_runtime_state()` or `ConfiguredLogger::file_runtime_state()`.
### How to Use