Enable custom levels and leave usize values for them
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.5k
- Forks
- 289
- Avg merge
- 55m
- Merged PRs (30d)
- 1
Description
https://docs.rs/log/latest/log/enum.Level.html gives the following numeric values of log levels:
#[repr(usize)]
pub enum Level {
Error = 1,
Warn = 2,
Info = 3,
Debug = 4,
Trace = 5,
}
This makes it impossible to add custom levels between the predefined levels, and limits us to 1 custom level above Error -- and the latter, since it's the minimum value of usize, should really be reserved for "disable all logs". To both make custom levels easier to create and reduce the likelihood that users will need them, I propose to change the levels to the following:
#[repr(usize)]
pub enum Level {
Off = 0,
MAX = 1,
Fatal = 500,
Error = 1000,
Warn = 2000,
Notice = 2500,
Info = 3000,
Verbose = 3500,
Debug = 4000,
Trace = 5000,
Fine = 6000,
Hyperfine = 7000,
Superhyperfine = 8000,
MIN = usize::MAX - 1,
All = usize::MAX,
}
with the default thresholds being:
- For debug builds and non-prod configs, 0..=4500 to stderr and file;
- For prod builds/configs, 0..=2250 to stderr and file, and 2251..=3250 to stdout and file, and 3251..=3750 to file only.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the current log::Level API referenced in the issue and review how its usize representation and thresholds are used. Confirm the intended custom-level and default-threshold semantics with maintainers; this is done only when an accepted design and compatibility plan are agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100