Skip to content

proposal: log/slog: add ParseLevel #68917

@jba

Description

@jba

Proposal Details

Level and LevelVar have UnmarshalText methods, but there no direct way to parse a string into a Level.
UnmarshalText is fine if the level is a flag, but not if it's, say, a query param. For that one has to write the awkward code:

slogLevel.UnmarshalText([]byte(r.FormValue("l"))

Add ParseLevel(string) (Level, error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions