Text-formatter-config-type
TextFormatterConfig is the public serializable config type used to describe text rendering behavior. It is a direct alias to the formatter config model used by config parsing, config serialization, and runtime formatter conversion.
Interface
pub type TextFormatterConfig = @utils.TextFormatterConfigoutput
TextFormatterConfig- Public formatter config object containing timestamp, level, target, field, template, color, markup, and style-tag settings.
Explanation
Detailed rules explaining key parameters and behaviors
- This is a type alias, not a runtime
TextFormatterinstance. - The current fields are
show_timestamp,show_level,show_target,show_fields,separator,field_separator,template,color_mode,color_support,style_markup,target_style_markup,fields_style_markup, andstyle_tags. TextFormatterConfig::new(...)constructs this type as the main code-side entry point.text_formatter_config_to_json(...),stringify_text_formatter_config(...), andTextFormatterConfig::to_formatter()all consume the same public config shape.
How to Use
Here are some specific examples provided.
When Need A Typed Serializable Formatter Policy
When formatter settings should remain structured config data before becoming a runtime formatter:
let config : TextFormatterConfig = TextFormatterConfig::new(show_timestamp=false)In this example, the formatter policy stays as a typed config object instead of a runtime formatter value.
When Need To Inspect Or Export Formatter Config Before Runtime Use
When configuration should be reviewed or serialized before a logger is built:
let config = TextFormatterConfig::new(template="[{level}] {message}")
println(stringify_text_formatter_config(config, pretty=true))In this example, the same public config type supports both inspection and later conversion.
Error Case
e.g.:
TextFormatterConfigitself does not have a runtime failure mode.If
style_tagsis empty, laterto_formatter()conversion simply creates no local tag registry.
Notes
Use
TextFormatterConfig::new(...)when you need a value of this type in code.Use
TextFormatterwhen you need the runtime rendering object directly instead of serializable config data.