1
0
Fork 0
mirror of https://github.com/chainguard-dev/clog synced 2026-07-06 22:12:46 +00:00
clog/slag/flag.go
Jason Hall 83244dc767
add a flag option (#10)
I don't like any of the names here, and we might want it to be in a
separate subpackage. This lets you say `--log-level=DEBUG` to set the
level. The default is still INFO.

---------

Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-02-06 11:01:13 -05:00

16 lines
343 B
Go

package slag
import "log/slog"
type Level slog.Level
func (l *Level) Set(s string) error {
var ll slog.Level
if err := ll.UnmarshalText([]byte(s)); err != nil {
return err
}
*l = Level(ll)
return nil
}
func (l *Level) String() string { return slog.Level(*l).String() }
func (l *Level) Level() slog.Level { return slog.Level(*l) }