Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creation of Level and LevelFilter from usize #460

Closed
WaDelma opened this issue Aug 27, 2021 · 2 comments
Closed

Allow creation of Level and LevelFilter from usize #460

WaDelma opened this issue Aug 27, 2021 · 2 comments

Comments

@WaDelma
Copy link
Contributor

WaDelma commented Aug 27, 2021

Currently Level::from_usize and LevelFilter::from_usize are private and cannot be used outside the crate.

I wanted to allow providing number via command line flag and use that to construct LevelFilter, but to do that I would need to replicate the code of those methods.

@KodrAus
Copy link
Contributor

KodrAus commented Nov 15, 2021

Hi @WaDelma 👋

I don't think we want to commit to an integer representation for these and the best approach would be for you to pick one for your use case and map them to log's. In my experience, integer representations, even well-understood ones like syslog, are an issue for interoperability because you've got no wiggle room for interpretation. You're just as likely to see 1 interpreted as error or as information.

@KodrAus KodrAus closed this as completed Nov 15, 2021
@phil-opp
Copy link

phil-opp commented Jan 2, 2023

I don't think we want to commit to an integer representation for these

Given that the types are repr(usize), the crate already commited to a specific integer representation in its public API. For example, the following prints 3:

fn main() {
    dbg!(log::LevelFilter::Info as usize);
}

(playground)

So I think it makes sense to expose the associated from_usize methods.

EFanZh pushed a commit to EFanZh/log that referenced this issue Jul 23, 2023
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.8 to 4.0.9.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](clap-rs/clap@v4.0.8...v4.0.9)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants