Skip to content

Move log levels up one #2

@beatgammit

Description

@beatgammit

It would be nice to have log levels start at 1 and have the default log level be 0. The meaning of the default log level could be user-configurable (e.g. Info or 3).

The reason here is that when parsing options with the default "flag" package, it's hard to know when a user wants 0 (trace) or the default (3). Currently, I have to do this:

flag.IntVar(&loglevel, "loglevel", lumber.Info, "some helpful text")

When there are multiple layers (e.g. config file and cmd options), it's more difficult to write fallback code (if not specified on the command-line, use config file}. The only way I could think of is to use an invalid default value (e.g. -1; ugly...) with flag or parse the config file first (not possible if a command-line option can specify where the config file is). This is a solvable problem, but not KISS IMHO.

Everything would be 1e6x easier if log levels started at 1, and 0 meant the default level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions