#3585·tracing

Add `tracing::log!()` to accept any log level

Author: eirnymCreated Jul 30, 2026Updated Aug 12, 2026

Feature Request

Add tracing::log!() to accept any log level which hides implementation details.

Crates

tracing

Motivation

There's situations where logging level for the same input could vary depending on a code flow. E.g. in one case it could be info! and in other it could be warn!. Also it includes

Proposal

copy one of logging macro and add explicit logging parameter.

The added value of target: module_path!() is enough for me to avoid code repetition (there's more to that, as one have to remember all subtle parameters like {}, so it's not so easy to get it right (see textual differences between trace!, debug! and other log levels to understand my pain)

drawbacks? one more macro.

Alternatives

use event!(target: module_path!(), level, ...) and other subtle differences described above or have constructions like below every time I need them (for which cargo clippy believes have very high cognitive complexity).

rust

if level == tracing::Level::INFO { 
	info!(/* whole long message with params */); 
} else if level == tracing::Level::WARNING { 
	warning!(/* whole long message with params */) 
} // etc