use core::sync::atomic::{AtomicU64, Ordering};
static OTHER: AtomicU64 = AtomicU64::new(0);
static MALFORMED: AtomicU64 = AtomicU64::new(0);
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct Counts {
pub other: u64,
pub malformed: u64,
}
pub fn counts() -> Counts {
Counts {
other: OTHER.load(Ordering::Relaxed),
malformed: MALFORMED.load(Ordering::Relaxed),
}
}
pub(crate) fn other(type_: &str) {
OTHER.fetch_add(1, Ordering::Relaxed);
#[cfg(feature = "tracing")]
tracing::debug!(target: "ccwire", type_, "stream-json frame of an unknown type");
#[cfg(not(feature = "tracing"))]
let _ = type_;
}
pub(crate) fn malformed(type_: &str, error: &str) {
MALFORMED.fetch_add(1, Ordering::Relaxed);
#[cfg(feature = "tracing")]
tracing::warn!(target: "ccwire", type_, error, "stream-json frame that didn't parse");
#[cfg(not(feature = "tracing"))]
let _ = (type_, error);
}