mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
add observability prelude module
The reason to do a wildcard import of the prelude instead of something
like
// src/observability/prelude.rs
pub(crate) use tracing::*;
// elsewhere
use crate::observability::prelude as o;
o::warn!("something");
is that we can't import traits like tracing::Instrument that way.
I'm generally not a fan of wildcard imports, but I think it can be okay
when it's a module in the same crate. There aren't really an backwards
compatibility hazards because it's your own code.
This commit is contained in:
parent
41c6fc8029
commit
bc5f31b3a2
2 changed files with 16 additions and 0 deletions
14
src/observability/prelude.rs
Normal file
14
src/observability/prelude.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//! Common tracing-related items intended to be wildcard imported in most
|
||||
//! modules:
|
||||
//!
|
||||
//! ```
|
||||
//! use crate::observability::prelude::*;
|
||||
//! ```
|
||||
//!
|
||||
//! This avoids diff churn in the imports when adding/removing log statements.
|
||||
//!
|
||||
//! [`tracing`] is re-exported as `t`, to avoid name collisions.
|
||||
#![allow(unused)]
|
||||
|
||||
pub(crate) use tracing as t;
|
||||
pub(crate) use tracing::Instrument;
|
||||
Loading…
Add table
Add a link
Reference in a new issue