2022-08-09 05:07:06 +02:00
|
|
|
#![deny(warnings)]
|
|
|
|
#![warn(unused_extern_crates)]
|
|
|
|
|
2021-10-02 01:02:36 +02:00
|
|
|
use num_enum::{IntoPrimitive, TryFromPrimitive};
|
2022-08-09 05:07:06 +02:00
|
|
|
use tracing_forest::{util::*, Tag};
|
|
|
|
|
|
|
|
pub mod macros;
|
|
|
|
pub mod middleware;
|
|
|
|
|
|
|
|
pub use tracing;
|
|
|
|
pub use tracing_forest;
|
|
|
|
pub use tracing_subscriber;
|
|
|
|
|
2022-08-18 02:36:45 +02:00
|
|
|
pub fn test_init() {
|
2022-08-09 05:07:06 +02:00
|
|
|
// tracing_subscriber::fmt::try_init()
|
|
|
|
let _ = tracing_forest::test_init();
|
|
|
|
/*
|
|
|
|
let _ = Registry::default().with(ForestLayer::new(
|
|
|
|
TestCapturePrinter::new(),
|
|
|
|
NoTag,
|
|
|
|
)).try_init();
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This is for tagging events. Currently not wired in.
|
|
|
|
pub fn event_tagger(_event: &Event) -> Option<Tag> {
|
|
|
|
None
|
|
|
|
}
|
2021-08-19 03:04:24 +02:00
|
|
|
|
2021-10-02 01:02:36 +02:00
|
|
|
#[derive(Debug, Clone, Copy, IntoPrimitive, TryFromPrimitive)]
|
|
|
|
#[repr(u64)]
|
2021-08-19 03:04:24 +02:00
|
|
|
pub enum EventTag {
|
2022-06-26 10:02:16 +02:00
|
|
|
AdminDebug,
|
2021-08-19 03:04:24 +02:00
|
|
|
AdminError,
|
|
|
|
AdminWarn,
|
|
|
|
AdminInfo,
|
|
|
|
RequestError,
|
|
|
|
RequestWarn,
|
|
|
|
RequestInfo,
|
|
|
|
RequestTrace,
|
|
|
|
SecurityCritical,
|
|
|
|
SecurityInfo,
|
|
|
|
SecurityAccess,
|
2021-10-17 13:28:04 +02:00
|
|
|
SecurityError,
|
2021-08-19 03:04:24 +02:00
|
|
|
FilterError,
|
|
|
|
FilterWarn,
|
|
|
|
FilterInfo,
|
|
|
|
FilterTrace,
|
|
|
|
PerfTrace,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl EventTag {
|
|
|
|
pub fn pretty(self) -> &'static str {
|
|
|
|
match self {
|
2022-06-26 10:02:16 +02:00
|
|
|
EventTag::AdminDebug => "admin.debug",
|
2021-08-19 03:04:24 +02:00
|
|
|
EventTag::AdminError => "admin.error",
|
|
|
|
EventTag::AdminWarn => "admin.warn",
|
|
|
|
EventTag::AdminInfo => "admin.info",
|
|
|
|
EventTag::RequestError => "request.error",
|
|
|
|
EventTag::RequestWarn => "request.warn",
|
|
|
|
EventTag::RequestInfo => "request.info",
|
|
|
|
EventTag::RequestTrace => "request.trace",
|
|
|
|
EventTag::SecurityCritical => "security.critical",
|
|
|
|
EventTag::SecurityInfo => "security.info",
|
|
|
|
EventTag::SecurityAccess => "security.access",
|
2021-10-17 13:28:04 +02:00
|
|
|
EventTag::SecurityError => "security.error",
|
2021-08-19 03:04:24 +02:00
|
|
|
EventTag::FilterError => "filter.error",
|
|
|
|
EventTag::FilterWarn => "filter.warn",
|
|
|
|
EventTag::FilterInfo => "filter.info",
|
|
|
|
EventTag::FilterTrace => "filter.trace",
|
|
|
|
EventTag::PerfTrace => "perf.trace",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn emoji(self) -> &'static str {
|
|
|
|
use EventTag::*;
|
|
|
|
match self {
|
2022-06-26 10:02:16 +02:00
|
|
|
AdminDebug => "🐛",
|
2021-10-17 13:28:04 +02:00
|
|
|
AdminError | FilterError | RequestError | SecurityError => "🚨",
|
2022-06-26 10:02:16 +02:00
|
|
|
AdminWarn | FilterWarn | RequestWarn => "⚠️",
|
2022-02-16 00:20:37 +01:00
|
|
|
AdminInfo | FilterInfo | RequestInfo | SecurityInfo => " ",
|
2021-08-19 03:04:24 +02:00
|
|
|
RequestTrace | FilterTrace | PerfTrace => "📍",
|
|
|
|
SecurityCritical => "🔐",
|
|
|
|
SecurityAccess => "🔓",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|