tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.51k stars 723 forks source link

tracing: Consider adding a prelude #167

Open hawkw opened 5 years ago

hawkw commented 5 years ago

Feature Request

Crates

tracing

Motivation

It might be useful for the tracing crate to expose a prelude containing commonly used types, traits, functions, macros, etc.

Proposal

We should add a prelude module to tracing. It should probably be fairly conservative, but should re-export at least the following:

I don't think there are currently any traits that need to be in scope to use tracing. If it eventually becomes necessary to add traits to the prelude, we should probably rename them with a prefix, to ensure they don't conflict with other imports of similarly named traits.

GeorgeHahn commented 4 years ago

I think this would be great! I've noticed that using sections either end up with a listing of most of the common macros or they churn frequently as usage changes.

I agree with your third bullet point - the display/debug sigils probably make field unnecessary in the prelude.

My one concern is that event seems like it could be a common identifier. Is the event! macro used commonly enough that it should be included in the prelude? I would like to include it for the sake of uniformity, but perhaps there's an argument for leaving it out.

I've implemented this in https://github.com/tokio-rs/tracing/pull/719

ch0wdreN commented 4 months ago

719 was closed, so I implemented it myself.

3019