Skip to content

Feature: Support parse_arg crate #3291

Open
@Kixunil

Description

@Kixunil

Feature Request

Crates

tracing

Motivation

tracing is very useful in various long-running daemons (and seems to be designed for them). Such daemons often need configuration, including the log level. When debugging one usually runs the daemon manually from command line an possibly wants to pass a --log-level argument to raise the level. There's a crate called parse_arg that provides a trivial trait for types so that they can be easily hooked into argument parsers. E.g. configure_me, which is configuration parser designed for long-running daemons uses this trait. Thus it'd make sense to provide the impls in tracing directly, so that people implementing such daemons can just activate the feature.

Proposal

Add an optional dependency on parse_arg that, when enabled, implements the ParseArg trait on all types that could be parsed from command line - typically those implementing FromStr such as Level and LevelFilter. I'll happily make a PR. The crate is stable and has conservative MSRV.

Alternatives

  • Do nothing and let everyone do the newtype thing - this means repeated boilerplate
  • Make a separate crate containing newtypes to be used with parse_arg - this isn't entirely terrible but creating a crate to contain two types with two trait impls seems too much. Also inserting an additional conversion is a bit annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions