diff --git a/tracing-core/src/metadata.rs b/tracing-core/src/metadata.rs index 7dd1f418c8..ee6a1f13df 100644 --- a/tracing-core/src/metadata.rs +++ b/tracing-core/src/metadata.rs @@ -283,6 +283,19 @@ impl Level { /// /// Designates very low priority, often extremely verbose, information. pub const TRACE: Level = Level(LevelInner::Trace); + + /// Returns the string representation of the `Level`. + /// + /// This returns the same string as the `fmt::Display` implementation. + pub fn as_str(&self) -> &'static str { + match *self { + Level::TRACE => "TRACE", + Level::DEBUG => "DEBUG", + Level::INFO => "INFO", + Level::WARN => "WARN", + Level::ERROR => "ERROR", + } + } } impl fmt::Display for Level {