mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
✨ Add configurable style markup modes
This commit is contained in:
@@ -206,6 +206,16 @@ test {
|
||||
}
|
||||
```
|
||||
|
||||
```mbt check
|
||||
test {
|
||||
let formatter = text_formatter(
|
||||
color_mode=ColorMode::Always,
|
||||
).without_style_markup()
|
||||
let logger = Logger::new(text_console_sink(formatter), target="raw")
|
||||
logger.info("<red>kept as raw text</>")
|
||||
}
|
||||
```
|
||||
|
||||
```mbt check
|
||||
test {
|
||||
let config = parse_logger_config_text(
|
||||
@@ -227,10 +237,21 @@ test {
|
||||
}
|
||||
```
|
||||
|
||||
```mbt check
|
||||
test {
|
||||
let config = parse_logger_config_text(
|
||||
"{\"sink\":{\"kind\":\"text_console\",\"text_formatter\":{\"color_mode\":\"always\",\"style_markup\":\"disabled\"}}}",
|
||||
)
|
||||
let logger = build_logger(config)
|
||||
logger.info("<red>still raw</>")
|
||||
}
|
||||
```
|
||||
|
||||
## Formatter Template / 模板格式
|
||||
|
||||
- supported tokens / 支持的 token: `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, `{fields}`
|
||||
- `color_mode` / `color_mode`: `never`, `auto`, `always`
|
||||
- `style_markup` / `style_markup`: `disabled`, `builtin`, `full`
|
||||
- inline style tags / inline 样式标签: `<red>...</>`, `<b>...</>`, `<#ff0000>...</>`, `<bg:#202020>...</>`
|
||||
- runtime style tags / 运行期样式标签: `TextStyle`, `StyleTagRegistry`, `style_tag_registry()`, `default_style_tag_registry()`, `set_tag(...)`, `define_alias(...)`
|
||||
- style tag priority / 标签优先级: formatter local `style_tags` > global style tag registry > builtin tags
|
||||
|
||||
Reference in New Issue
Block a user