saucelabs / forwarder

Forwarder is a production-ready, fast MITM proxy with PAC support. It's suitable for debugging, intercepting and manipulating HTTP traffic. It's used as a core component of Sauce Labs Sauce Connect Proxy.
https://forwarder-proxy.io
Mozilla Public License 2.0
200 stars 13 forks source link

log: error level is not recognised as default by anyflag #832

Closed Choraden closed 3 weeks ago

Choraden commented 4 weeks ago

Error level evaluates to 0:

const (
    ErrorLevel Level = iota
    InfoLevel
    DebugLevel
)

That makes anyflag ignore this value as default:

func (v *Value[T]) String() string {
    if v.redact != nil {
        return v.redact(*v.value)
    }

    if v.value == nil || reflect.ValueOf(*v.value).IsZero() {
        return ""
    }
    return fmt.Sprint(*v.value)
}

As a result, default log level is not printed in help:

    --log-level <error|info|debug> (env FORWARDER_LOG_LEVEL)
        Log level.
mmatczuk commented 3 weeks ago

How about starting form 1 making 0 undefined?