mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-24 00:42:18 +00:00
📝 refine formatter config docs
This commit is contained in:
@@ -30,6 +30,7 @@ pub fn default_text_formatter_config() -> TextFormatterConfig {
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- This helper returns the same baseline config value used by `text_console(...)`, `file(...)`, and `SinkConfig::new(...)` defaults.
|
||||
- The implementation is exactly `TextFormatterConfig::new()`, so it stays aligned with the constructor defaults rather than duplicating a separate preset object.
|
||||
- It is a config object, not a runtime `TextFormatter`.
|
||||
- Call `to_formatter()` when a runtime formatter is needed.
|
||||
|
||||
@@ -58,3 +59,5 @@ e.g.:
|
||||
1. Use this helper for explicit config composition.
|
||||
|
||||
2. Use `text_formatter(...)` when you want a runtime formatter directly.
|
||||
|
||||
3. `parse_logger_config_text(...)` also falls back to this same baseline when a sink omits its nested `text_formatter` object.
|
||||
|
||||
@@ -35,8 +35,9 @@ Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- This helper forwards the stored visibility flags, separators, template, color settings, and markup settings into `text_formatter(...)`.
|
||||
- When `style_tags` is empty, the runtime formatter is built without a local style-tag registry.
|
||||
- When `style_tags` is non-empty, the config map is converted into a fresh `StyleTagRegistry` before formatter construction.
|
||||
- When `style_tags` is non-empty, the config map is converted into a fresh `StyleTagRegistry` and each stored tag is registered on that new registry before formatter construction.
|
||||
- This conversion does not mutate the source config object.
|
||||
- Sync and async config-driven builder paths both rely on this helper when a text formatter config must become a concrete runtime formatter.
|
||||
|
||||
### How to Use
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ Detailed rules explaining key parameters and behaviors
|
||||
- `to_formatter()` converts config into a runtime `TextFormatter`.
|
||||
- `style_tags` are stored as concrete style objects instead of alias-style runtime behavior.
|
||||
- This config type is used by `SinkConfig`, `LoggerConfig`, and config-driven sink assembly.
|
||||
- The constructor defaults match the parser defaults: timestamps, level, target, and fields are shown by default; separators default to a single space; `template` defaults to empty; `color_mode` defaults to `Never`; `color_support` defaults to `TrueColor`; `style_markup` defaults to `Full`; and target/field-specific markup defaults to `Disabled`.
|
||||
- `parse_logger_config_text(...)` rehydrates formatter config through this same constructor path, so omitted formatter fields fall back to the same defaults whether config is built in code or parsed from JSON.
|
||||
|
||||
### How to Use
|
||||
|
||||
@@ -93,3 +95,5 @@ e.g.:
|
||||
1. Prefer this API when formatter behavior must be stored, parsed, or serialized.
|
||||
|
||||
2. Prefer `text_formatter(...)` when writing direct runtime code without config.
|
||||
|
||||
3. Use `default_text_formatter_config()` when callers want the standard formatter baseline without spelling out every field manually.
|
||||
|
||||
Reference in New Issue
Block a user