mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
✨ Add ANSI color support fallback modes
This commit is contained in:
@@ -281,6 +281,7 @@ match logger.file_runtime_state() {
|
||||
- `QueueConfig`, `TextFormatterConfig`, and `SinkConfig` can also be exported independently through `queue_config_to_json(...)` / `stringify_queue_config(...)`, `text_formatter_config_to_json(...)` / `stringify_text_formatter_config(...)`, and `sink_config_to_json(...)` / `stringify_sink_config(...)`.
|
||||
- Supported keys include `min_level`, `target`, `timestamp`, `sink.kind`, `sink.path`, `sink.append`, `sink.auto_flush`, `sink.rotation`, `sink.text_formatter`, and `queue`.
|
||||
- `TextFormatter` and `TextFormatterConfig` now include `color_mode = Never | Auto | Always` for ANSI text coloring control.
|
||||
- `TextFormatter` and `TextFormatterConfig` also include `color_support = basic | truecolor` so hex / RGB styling can be forced to downgrade to basic ANSI colors.
|
||||
- `TextFormatter` and `TextFormatterConfig` also include `style_markup = disabled | builtin | full` so callers can choose whether style markup is parsed and whether custom tags are active.
|
||||
- `target_style_markup` and `fields_style_markup` independently control whether `target` and `fields` are parsed for style markup.
|
||||
- `message` also supports lightweight inline style tags such as `<red>...</>`, `<b>...</>`, `<#ff0000>...</>`, and `<bg:#202020>...</>`.
|
||||
@@ -314,6 +315,7 @@ match logger.file_runtime_state() {
|
||||
- `file_sink_state_to_json(...)`, `stringify_file_sink_state(...)`, `runtime_file_state_to_json(...)`, and `stringify_runtime_file_state(...)` can export file and queued-file snapshots directly as JSON for diagnostics or reporting.
|
||||
- `sink.text_formatter.template` currently supports fixed tokens: `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, and `{fields}`.
|
||||
- `sink.text_formatter.color_mode` currently supports `never`, `auto`, and `always`.
|
||||
- `sink.text_formatter.color_support` currently supports `basic` and `truecolor`.
|
||||
- `sink.text_formatter.style_markup` currently supports `disabled`, `builtin`, and `full`.
|
||||
- `sink.text_formatter.target_style_markup` and `sink.text_formatter.fields_style_markup` currently support `disabled`, `builtin`, and `full`.
|
||||
- `sink.text_formatter.style_tags.<name>` currently supports `fg`, `bg`, `bold`, `dim`, `italic`, and `underline`.
|
||||
|
||||
@@ -19,6 +19,7 @@ version 0.4.0
|
||||
- feat: add builtin semantic style tags such as `accent`, `info`, `success`, `warning`, `danger`, and `muted`
|
||||
- feat: add independent `target_style_markup` and `fields_style_markup` controls for `TextFormatter` and `TextFormatterConfig`
|
||||
- feat: support named closing tags like `</red>` alongside the existing short close `</>`
|
||||
- feat: add `ColorSupport = Basic | TrueColor` and support `sink.text_formatter.color_support` so hex / RGB styles can downgrade to basic ANSI colors
|
||||
|
||||
### Test
|
||||
|
||||
@@ -33,6 +34,7 @@ version 0.4.0
|
||||
- test: cover builtin semantic tag rendering and confirm user overrides still take precedence
|
||||
- test: cover target and field markup rendering, plus config roundtrip for the new formatter markup scopes
|
||||
- test: cover named closing tags, mixed short/named closing, and unmatched named-close fallback behavior
|
||||
- test: cover basic color-support downgrade for hex foreground/background rendering in runtime and config paths
|
||||
|
||||
### Example
|
||||
|
||||
@@ -49,3 +51,4 @@ version 0.4.0
|
||||
- JSON config currently supports concrete style objects only; alias-style declarations remain runtime-only
|
||||
- users can now decide whether custom style parsing is enabled through runtime formatter APIs or `sink.text_formatter.style_markup`
|
||||
- `fields_style_markup` currently styles field values only and intentionally leaves field keys raw
|
||||
- `basic` color support currently keeps ANSI styling but downgrades hex / RGB colors to the nearest basic ANSI color family
|
||||
|
||||
Reference in New Issue
Block a user