0.5.1-pre.002
This commit is contained in:
58
ks-logging/src/config.rs
Normal file
58
ks-logging/src/config.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
// file: ks-logging/src/config.rs
|
||||
// version: 5
|
||||
|
||||
//! 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 `ks-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>,
|
||||
}
|
||||
5
ks-logging/src/constants.rs
Normal file
5
ks-logging/src/constants.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
// file: ks-logging/src/constants.rs
|
||||
// version: 3
|
||||
|
||||
/// Canonical tracing target for this crate.
|
||||
pub(crate) const TRACING_TARGET: &str = "ks-logging";
|
||||
31
ks-logging/src/lib.rs
Normal file
31
ks-logging/src/lib.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
// file: ks-logging/src/lib.rs
|
||||
// version: 7
|
||||
|
||||
//! Logging and tracing initialization for applications and workers.
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
mod config;
|
||||
mod constants;
|
||||
mod tracing_runtime;
|
||||
|
||||
/// Canonical tracing target for this crate.
|
||||
pub(crate) use self::constants::TRACING_TARGET;
|
||||
|
||||
/// Exposes the legacy file route shape kept for early file-only callers.
|
||||
pub use self::config::LogFileRoute;
|
||||
/// Exposes one configured logging output target.
|
||||
pub use self::config::LogTargetConfig;
|
||||
/// Exposes one configured tracing target filter.
|
||||
pub use self::config::LogTargetFilterConfig;
|
||||
/// Exposes the logging configuration consumed by this crate.
|
||||
pub use self::config::LoggingConfig;
|
||||
/// Exposes the guard that keeps non-blocking logging workers alive.
|
||||
pub use self::tracing_runtime::LoggingGuard;
|
||||
/// Exposes initialization from a raw logging configuration section.
|
||||
pub use self::tracing_runtime::init_logging;
|
||||
/// Returns the canonical tracing target.
|
||||
pub fn tracing_target() -> &'static str {
|
||||
return crate::TRACING_TARGET;
|
||||
}
|
||||
1121
ks-logging/src/tracing_runtime.rs
Normal file
1121
ks-logging/src/tracing_runtime.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user