2024-11-14 04:31:29 +00:00
|
|
|
#![allow(clippy::disallowed_macros)]
|
|
|
|
|
|
2024-06-11 01:26:31 +00:00
|
|
|
pub mod capture;
|
2024-06-11 00:14:53 +00:00
|
|
|
pub mod color;
|
2025-02-06 03:14:37 +00:00
|
|
|
pub mod console;
|
2024-06-11 00:15:29 +00:00
|
|
|
pub mod fmt;
|
2024-11-11 20:12:20 +00:00
|
|
|
pub mod fmt_span;
|
2024-06-08 01:13:20 +00:00
|
|
|
mod reload;
|
2024-06-13 02:15:51 +00:00
|
|
|
mod suppress;
|
2024-06-08 01:13:20 +00:00
|
|
|
|
2025-11-27 18:20:54 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
pub use tracing::{Level, subscriber::Subscriber};
|
2024-06-11 01:26:31 +00:00
|
|
|
pub use tracing_core::{Event, Metadata};
|
2024-06-10 06:02:17 +00:00
|
|
|
pub use tracing_subscriber::EnvFilter;
|
2024-06-08 01:13:20 +00:00
|
|
|
|
2025-11-27 18:20:54 +00:00
|
|
|
pub use self::{
|
|
|
|
|
capture::Capture,
|
|
|
|
|
console::{ConsoleFormat, ConsoleWriter, is_systemd_mode},
|
|
|
|
|
reload::{LogLevelReloadHandles, ReloadHandle},
|
|
|
|
|
suppress::Suppress,
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-26 00:19:35 +00:00
|
|
|
/// Logging subsystem. This is a singleton member of super::Server which holds
|
|
|
|
|
/// all logging and tracing related state rather than shoving it all in
|
|
|
|
|
/// super::Server directly.
|
2025-11-27 18:20:54 +00:00
|
|
|
pub struct Logging {
|
|
|
|
|
/// Subscriber assigned to globals and defaults; may also be NoSubscriber.
|
|
|
|
|
pub subscriber: Arc<dyn Subscriber + Send + Sync>,
|
|
|
|
|
|
2024-06-26 00:19:35 +00:00
|
|
|
/// General log level reload handles.
|
|
|
|
|
pub reload: LogLevelReloadHandles,
|
|
|
|
|
|
|
|
|
|
/// Tracing capture state for ephemeral/oneshot uses.
|
2025-11-27 18:20:54 +00:00
|
|
|
pub capture: Arc<capture::State>,
|
2024-06-26 00:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-11 01:26:31 +00:00
|
|
|
// Wraps for logging macros. Use these macros rather than extern tracing:: or
|
|
|
|
|
// log:: crates in project code. ::log and ::tracing can still be used if
|
|
|
|
|
// necessary but discouraged. Remember debug_ log macros are also exported to
|
|
|
|
|
// the crate namespace like these.
|
2024-06-08 01:13:20 +00:00
|
|
|
|
2024-10-24 11:16:44 +00:00
|
|
|
#[macro_export]
|
2025-04-04 23:04:13 +00:00
|
|
|
#[collapse_debuginfo(yes)]
|
2024-10-24 11:16:44 +00:00
|
|
|
macro_rules! event {
|
2025-02-23 01:17:45 -05:00
|
|
|
( $level:expr_2021, $($x:tt)+ ) => { ::tracing::event!( $level, $($x)+ ) }
|
2024-10-24 11:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-08 01:13:20 +00:00
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! error {
|
2024-07-09 03:31:58 +00:00
|
|
|
( $($x:tt)+ ) => { ::tracing::error!( $($x)+ ) }
|
2024-06-08 01:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! warn {
|
2024-07-09 03:31:58 +00:00
|
|
|
( $($x:tt)+ ) => { ::tracing::warn!( $($x)+ ) }
|
2024-06-08 01:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! info {
|
2024-07-09 03:31:58 +00:00
|
|
|
( $($x:tt)+ ) => { ::tracing::info!( $($x)+ ) }
|
2024-06-08 01:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! debug {
|
2024-07-09 03:31:58 +00:00
|
|
|
( $($x:tt)+ ) => { ::tracing::debug!( $($x)+ ) }
|
2024-06-08 01:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! trace {
|
2024-07-09 03:31:58 +00:00
|
|
|
( $($x:tt)+ ) => { ::tracing::trace!( $($x)+ ) }
|
2024-06-08 01:13:20 +00:00
|
|
|
}
|