wp-log
wp-log bundles the structured logging macros and runtime configuration helpers used inside the WarpParse platform. 6 pre-defined targets (ctrl, data, rule, dfx, mtrc, kdb) keep service logs consistent across control plane, data plane and diagnostics modules, while the configuration helpers wire those targets into log4rs with rolling outputs and environment-friendly defaults.
🇨🇳 该 crate 提供 WarpParse 平台统一的 6 域日志宏,以及针对
log4rs的默认配置与序列化/反序列化能力,可直接用于落地配置文件或测试脚本。
Highlights
- Structured macros wrap
logso call sites stay terse but targets remain consistent. LogConfmodels your logging policy with full Serde support for TOML/JSON configs.- One call to
log_initwires rolling file + console appenders throughlog4rs. PRINT_STATenv-gatedprintln_mtrc!enables lightweight metrics dumps in smoke tests.
Quick Start
Add the dependency:
[]
= "0.1"
Configure and initialize logging:
use ;
use ;
Using TOML configuration
LogConf derives Serialize/Deserialize, so you can load structured config files:
# log.toml
= "warn" # default/root level
= "Both" # Console | File | Both
[] # optional per-target overrides
= "info"
= "debug"
[]
= "./data/logs" # log directory; file name derives from the binary name
let conf: LogConf = from_str?;
log_init?;
Set PRINT_STAT=true to make println_mtrc! emit lightweight counters during tests or local experiments.
Feature Flags
std(default): enables theorion_confhelpers used bylog_init/log_for_test. Disable forno_stdbuilds where only the macros are needed.
License
Licensed under the Elastic License 2.0. See LICENSE (if bundled) or https://www.elastic.co/licensing/elastic-license for details.