59 lines
2.1 KiB
Rust
59 lines
2.1 KiB
Rust
// file: kb_logging/src/config.rs
|
|
// version: 3
|
|
|
|
//! Logging configuration data structures consumed by the tracing runtime.
|
|
|
|
/// Legacy file route shape kept for early callers that only need human file logs.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct LogFileRoute {
|
|
/// Output file path.
|
|
pub file: std::string::String,
|
|
/// Logging level filter.
|
|
pub level: std::string::String,
|
|
/// Target filters handled by this route.
|
|
pub targets: std::vec::Vec<std::string::String>,
|
|
}
|
|
|
|
/// One target-level filter shared by routes that include the wildcard target.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct LogTargetFilterConfig {
|
|
/// Tracing target or crate prefix.
|
|
pub target: std::string::String,
|
|
/// Minimum level assigned to this target.
|
|
pub level: std::string::String,
|
|
}
|
|
|
|
/// One logging output route.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct LogTargetConfig {
|
|
/// Route name used for diagnostics.
|
|
pub name: std::string::String,
|
|
/// Enables this route.
|
|
pub enabled: bool,
|
|
/// Sink kind: `console` or `file`.
|
|
pub sink: std::string::String,
|
|
/// Minimum level for this route.
|
|
pub level: std::string::String,
|
|
/// File path for file sinks, empty for console sinks.
|
|
pub path: std::string::String,
|
|
/// Rotation mode: `none`, `never`, `daily`, or `hourly`.
|
|
pub rotation: std::string::String,
|
|
/// Format kind: `human`, `compact`, `pretty`, or `json`.
|
|
pub format: std::string::String,
|
|
/// Enables ANSI formatting for this route.
|
|
pub ansi: bool,
|
|
/// Included tracing targets or wildcard target globs.
|
|
pub targets: std::vec::Vec<std::string::String>,
|
|
}
|
|
|
|
/// Logging configuration consumed by `kb_logging` before profile binding exists.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct LoggingConfig {
|
|
/// Default log level used when a route does not provide target directives.
|
|
pub default_level: std::string::String,
|
|
/// Output routes.
|
|
pub targets: std::vec::Vec<crate::LogTargetConfig>,
|
|
/// Target-specific overrides appended to wildcard routes.
|
|
pub target_filters: std::vec::Vec<crate::LogTargetFilterConfig>,
|
|
}
|