2.4 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| sink-config-type | api | config | 20260707 | Public sink config type re-exported from config_model for serializable built-in sink settings. |
|
Sink-config-type
SinkConfig is the public serializable config type used to describe the built-in sink shape and its related settings. On the root src facade, it is re-exported from src/config_model, which is the real owner of the concrete sink config model.
Interface
pub using @config_model { type SinkConfig }
output
SinkConfig- Public sink config object containingkind,path,append,auto_flush,rotation, andtext_formatter.
Explanation
Detailed rules explaining key parameters and behaviors
- This root surface is a re-export, not the concrete owner definition.
- The concrete type lives in
@config_model.SinkConfig, not in@utils. - The current fields are
kind : SinkKind,path : String,append : Bool,auto_flush : Bool,rotation : FileRotation?, andtext_formatter : TextFormatterConfig. SinkConfig::new(...)constructs this type as the main code-side entry point.sink_config_to_json(...),stringify_sink_config(...), andbuild_logger(...)all consume the same public config shape.
How to Use
Here are some specific examples provided.
When Need A Typed Built-in Sink Description
When sink selection and file/text settings should remain config data before logger construction:
let sink : SinkConfig = SinkConfig::new(kind=SinkKind::TextConsole)
In this example, the sink choice stays as a typed config object instead of becoming a runtime sink immediately.
When Need To Inspect Or Export Sink Settings
When a sink definition should be serialized or reviewed before build time:
let sink = SinkConfig::new(kind=SinkKind::File, path="app.log")
println(stringify_sink_config(sink, pretty=true))
In this example, the same public config type supports both inspection and later runtime assembly.
Error Case
e.g.:
-
SinkConfigitself does not have a runtime failure mode. -
File-oriented fields can still be present on a non-file sink config, but those values may remain unused by the runtime builder.
Notes
-
Use
SinkConfig::new(...)when you need a value of this type in code. -
Use concrete sink constructors when you need a runtime sink directly instead of serializable config data.