mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
📝 Add configured logger file state API docs
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
---
|
||||
name: configured-logger-file-flush-failures
|
||||
group: api
|
||||
category: runtime
|
||||
update-time: 20260512
|
||||
description: Read the number of flush failures recorded by the configured runtime file sink.
|
||||
key-word:
|
||||
- logger
|
||||
- runtime
|
||||
- file
|
||||
- public
|
||||
---
|
||||
|
||||
## Configured-logger-file-flush-failures
|
||||
|
||||
Read the number of flush failures recorded by a `ConfiguredLogger` file sink. This helper is useful for diagnosing durability-path problems on file-backed loggers.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn ConfiguredLogger::file_flush_failures(self : ConfiguredLogger) -> Int {}
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : ConfiguredLogger` - Config-driven runtime logger whose flush-failure counter should be inspected.
|
||||
|
||||
#### output
|
||||
|
||||
- `Int` - Number of recorded flush failures.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- File-backed sinks report their recorded flush-failure count.
|
||||
- Queued file sinks forward the metric from the wrapped file sink.
|
||||
- Non-file sinks return `0`.
|
||||
- The counter is cumulative until reset.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need Durability-path Diagnostics
|
||||
|
||||
When support output should show flush-path instability:
|
||||
```moonbit
|
||||
let count = logger.file_flush_failures()
|
||||
```
|
||||
|
||||
In this example, the configured logger exposes whether flush attempts have been failing.
|
||||
|
||||
#### When Inspect Effects Of Auto-flush Policy
|
||||
|
||||
When runtime durability tuning should be inspected operationally:
|
||||
```moonbit
|
||||
ignore(logger.file_flush_failures())
|
||||
```
|
||||
|
||||
In this example, callers can correlate flush failures with runtime file policy choices.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If the configured sink is not file-backed, the method returns `0`.
|
||||
|
||||
- If callers need current policy and counters together, `file_state()` is the better API.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper when flush-path reliability matters.
|
||||
|
||||
2. Pair it with `file_auto_flush()` and `file_flush()` when diagnosing durability behavior.
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
name: configured-logger-file-open-failures
|
||||
group: api
|
||||
category: runtime
|
||||
update-time: 20260512
|
||||
description: Read the number of open failures recorded by the configured runtime file sink.
|
||||
key-word:
|
||||
- logger
|
||||
- runtime
|
||||
- file
|
||||
- public
|
||||
---
|
||||
|
||||
## Configured-logger-file-open-failures
|
||||
|
||||
Read the number of open failures recorded by a `ConfiguredLogger` file sink. This helper is useful for diagnosing file-availability or reopen problems.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn ConfiguredLogger::file_open_failures(self : ConfiguredLogger) -> Int {}
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : ConfiguredLogger` - Config-driven runtime logger whose open-failure counter should be inspected.
|
||||
|
||||
#### output
|
||||
|
||||
- `Int` - Number of recorded open failures.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- File-backed sinks report their recorded open-failure count.
|
||||
- Queued file sinks forward the metric from the wrapped file sink.
|
||||
- Non-file sinks return `0`.
|
||||
- The counter is cumulative until reset.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need File Availability Diagnostics
|
||||
|
||||
When operators should see whether file open or reopen failed:
|
||||
```moonbit
|
||||
let count = logger.file_open_failures()
|
||||
```
|
||||
|
||||
In this example, the configured logger exposes the open-failure metric directly.
|
||||
|
||||
#### When Validate Recovery Logic
|
||||
|
||||
When tests or support code should inspect whether reopen attempts failed:
|
||||
```moonbit
|
||||
ignore(logger.file_open_failures())
|
||||
```
|
||||
|
||||
In this example, the counter helps confirm whether file-open problems occurred during runtime.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If the configured sink is not file-backed, the method returns `0`.
|
||||
|
||||
- If callers need the full file status snapshot rather than one counter, `file_state()` is the better API.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper for focused file-open diagnostics.
|
||||
|
||||
2. Pair it with `file_reopen(...)` and `file_available()` during recovery analysis.
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
name: configured-logger-file-reset-failure-counters
|
||||
group: api
|
||||
category: runtime
|
||||
update-time: 20260512
|
||||
description: Reset the file failure counters recorded by the configured runtime file sink.
|
||||
key-word:
|
||||
- logger
|
||||
- runtime
|
||||
- file
|
||||
- public
|
||||
---
|
||||
|
||||
## Configured-logger-file-reset-failure-counters
|
||||
|
||||
Reset the file failure counters recorded by a `ConfiguredLogger`. This helper clears open, write, flush, and rotation failure metrics together.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn ConfiguredLogger::file_reset_failure_counters(self : ConfiguredLogger) -> Bool {}
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : ConfiguredLogger` - Config-driven runtime logger whose file failure counters should be cleared.
|
||||
|
||||
#### output
|
||||
|
||||
- `Bool` - Whether the reset was applied.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- File-backed sinks clear all file failure counters together.
|
||||
- Queued file sinks forward the reset behavior to the wrapped file sink.
|
||||
- Non-file sinks return `false`.
|
||||
- This helper is useful after diagnostics, recovery, or controlled tests.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need A Fresh Diagnostics Baseline
|
||||
|
||||
When previous failure history should be cleared before a new observation window:
|
||||
```moonbit
|
||||
ignore(logger.file_reset_failure_counters())
|
||||
```
|
||||
|
||||
In this example, future failures can be measured from a clean baseline.
|
||||
|
||||
#### When Validate Post-recovery Behavior
|
||||
|
||||
When recovery logic should clear old counters before rechecking health:
|
||||
```moonbit
|
||||
ignore(logger.file_reset_failure_counters())
|
||||
ignore(logger.file_open_failures())
|
||||
```
|
||||
|
||||
In this example, the configured logger starts a new diagnostics window after reset.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If the configured sink is not file-backed, the method returns `false`.
|
||||
|
||||
- If callers need the current values before clearing them, they should read the counters or `file_state()` first.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper after diagnostics or recovery, not before capturing needed evidence.
|
||||
|
||||
2. It is the reset companion for the file failure-counter helpers.
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
name: configured-logger-file-rotation-failures
|
||||
group: api
|
||||
category: runtime
|
||||
update-time: 20260512
|
||||
description: Read the number of rotation failures recorded by the configured runtime file sink.
|
||||
key-word:
|
||||
- logger
|
||||
- runtime
|
||||
- file
|
||||
- public
|
||||
---
|
||||
|
||||
## Configured-logger-file-rotation-failures
|
||||
|
||||
Read the number of rotation failures recorded by a `ConfiguredLogger` file sink. This helper is useful when runtime rotation behavior should be observed operationally.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn ConfiguredLogger::file_rotation_failures(self : ConfiguredLogger) -> Int {}
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : ConfiguredLogger` - Config-driven runtime logger whose rotation-failure counter should be inspected.
|
||||
|
||||
#### output
|
||||
|
||||
- `Int` - Number of recorded rotation failures.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- File-backed sinks report their recorded rotation-failure count.
|
||||
- Queued file sinks forward the metric from the wrapped file sink.
|
||||
- Non-file sinks return `0`.
|
||||
- The counter is cumulative until reset.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need Rotation-specific Diagnostics
|
||||
|
||||
When support output should reveal whether rotation is failing:
|
||||
```moonbit
|
||||
let count = logger.file_rotation_failures()
|
||||
```
|
||||
|
||||
In this example, the configured logger exposes a focused metric for rotation-path health.
|
||||
|
||||
#### When Validate Runtime Rotation Tuning
|
||||
|
||||
When changed rotation settings should be checked in operation:
|
||||
```moonbit
|
||||
ignore(logger.file_rotation_failures())
|
||||
```
|
||||
|
||||
In this example, callers can observe whether runtime rotation changes introduced problems.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If the configured sink is not file-backed, the method returns `0`.
|
||||
|
||||
- If callers need both rotation config and failure metrics, they should combine this helper with `file_rotation_config()` or `file_state()`.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper when diagnosing file rotation reliability.
|
||||
|
||||
2. It is especially relevant when runtime rotation policy can change after startup.
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
name: configured-logger-file-state
|
||||
group: api
|
||||
category: runtime
|
||||
update-time: 20260512
|
||||
description: Read the current file sink snapshot from a configured runtime logger.
|
||||
key-word:
|
||||
- logger
|
||||
- runtime
|
||||
- file
|
||||
- public
|
||||
---
|
||||
|
||||
## Configured-logger-file-state
|
||||
|
||||
Read the current file sink snapshot from a `ConfiguredLogger`. This helper exposes path, availability, policy flags, rotation config, and failure counters as one object.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn ConfiguredLogger::file_state(self : ConfiguredLogger) -> FileSinkState {}
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : ConfiguredLogger` - Config-driven runtime logger whose file state snapshot should be inspected.
|
||||
|
||||
#### output
|
||||
|
||||
- `FileSinkState` - Current file sink snapshot.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- File-backed sinks return a live snapshot of file state.
|
||||
- Queued file sinks forward the snapshot from the wrapped file sink.
|
||||
- Non-file sinks return a fallback empty-state snapshot.
|
||||
- This helper is broader than individual file counters or policy accessors because it aggregates core file status into one read.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need A Full File Health Snapshot
|
||||
|
||||
When diagnostics should inspect runtime file state as one object:
|
||||
```moonbit
|
||||
let state = logger.file_state()
|
||||
```
|
||||
|
||||
In this example, callers receive a single file-state snapshot instead of querying each property separately.
|
||||
|
||||
#### When Need To Export File Runtime Diagnostics
|
||||
|
||||
When a support path should serialize current file state:
|
||||
```moonbit
|
||||
println(stringify_file_sink_state(logger.file_state(), pretty=true))
|
||||
```
|
||||
|
||||
In this example, the configured logger snapshot can be exported directly through existing JSON helpers.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If the configured sink is not file-backed, the returned snapshot is a fallback empty-style state rather than a live file view.
|
||||
|
||||
- If callers also need queue context for queued file sinks, `file_runtime_state()` is the richer API.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper for the main one-shot file status snapshot.
|
||||
|
||||
2. Prefer it over individual counters when broader file diagnostics are needed.
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
name: configured-logger-file-write-failures
|
||||
group: api
|
||||
category: runtime
|
||||
update-time: 20260512
|
||||
description: Read the number of write failures recorded by the configured runtime file sink.
|
||||
key-word:
|
||||
- logger
|
||||
- runtime
|
||||
- file
|
||||
- public
|
||||
---
|
||||
|
||||
## Configured-logger-file-write-failures
|
||||
|
||||
Read the number of write failures recorded by a `ConfiguredLogger` file sink. This helper is useful for diagnosing runtime write-path problems.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn ConfiguredLogger::file_write_failures(self : ConfiguredLogger) -> Int {}
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : ConfiguredLogger` - Config-driven runtime logger whose write-failure counter should be inspected.
|
||||
|
||||
#### output
|
||||
|
||||
- `Int` - Number of recorded write failures.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- File-backed sinks report their recorded write-failure count.
|
||||
- Queued file sinks forward the metric from the wrapped file sink.
|
||||
- Non-file sinks return `0`.
|
||||
- The counter is cumulative until reset.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need Runtime Write-path Diagnostics
|
||||
|
||||
When support output should show whether writes have been failing:
|
||||
```moonbit
|
||||
let count = logger.file_write_failures()
|
||||
```
|
||||
|
||||
In this example, callers get a focused signal for file write-path health.
|
||||
|
||||
#### When Compare Sink Health After Recovery
|
||||
|
||||
When recovery logic should verify whether new failures still occur:
|
||||
```moonbit
|
||||
ignore(logger.file_write_failures())
|
||||
```
|
||||
|
||||
In this example, the metric helps measure whether runtime writes improved after intervention.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If the configured sink is not file-backed, the method returns `0`.
|
||||
|
||||
- If callers need a fuller view of file health, `file_state()` or `file_runtime_state()` may be better APIs.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper for focused write-failure visibility.
|
||||
|
||||
2. Pair it with `file_flush_failures()` when diagnosing output-path instability.
|
||||
Reference in New Issue
Block a user