Expose logging levels #459
Conversation
|
Hey @WaDelma 👋 There probably isn't a great reason for this to be pub fn iter_all() -> impl Iterator<Item = Level> {
..
}That way in your code you could call something like: let names = Level::iter_all().map(|l| l.as_str()).collect();The reason I think we should avoid making the array public is that it would be a breaking change to add any more levels (as unlikely as that is) because the type would change from |
|
Makes sense. I added such static methods for both |
| } | ||
|
|
||
| /// Iterate through all supported logging levels | ||
| pub fn iter() -> impl Iterator<Item = Self> { |
There was a problem hiding this comment.
It might be worth documenting something about the order of these fields. Using from_usize we’re effectively returning them in priority order.
What do you think?
* Refactor: Avoid parsing `package.version()` twice in `ops::resolve` and `ops::install` * Optimize Resolution: Replace `Package<Meta>` with two `CompactStrings`: `name` and `version` * Use `CompactString` for `BinstallError::CratesIoApi::crate_name` * Use `CompactString` for `BinstallError::VersionParse::v` * Use `CompactString` for `BinstallError::VersionReq::req` * Use `CompactString` for `BinstallError::VersionUnavailable::crate_name` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
I am using
FromStrimplementation ofLevelFilterto parse logging level given by user via command line flag. In case user gives invalid logging level I want to print list of allowed values. Currently I have to replicateLOG_LEVEL_NAMESarray in my code and remember to keep it in sync (It is probably unlikely it changes that much though).One question I have is that is there a reason it is
staticinstead ofconst?