Commit 9702bf5
authored
## Motivation
Get the string representation of the `Level` is quite a common usecase.
Without this method, I normally need to implement it by myself, which
is fairly noisy.
```rust
#[inline]
fn level_to_str(level: &tracing::Level) -> &'static str {
match *level {
tracing::Level::TRACE => "TRACE",
tracing::Level::DEBUG => "DEBUG",
tracing::Level::INFO => "INFO",
tracing::Level::WARN => "WARN",
tracing::Level::ERROR => "ERROR"
}
}
```
## Solution
Add an `as_str()` method for `Level`. Similar to [log::Level::as_str()][1].
[1]: https://docs.rs/log/0.4.14/log/enum.Level.html#method.as_str
1 parent 2920a89 commit 9702bf5
1 file changed
+13
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
286 | 299 | | |
287 | 300 | | |
288 | 301 | | |
| |||
0 commit comments