|
|
@ -3,9 +3,13 @@ package main |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"darvaza.org/sidecar/pkg/logger/zerolog" |
|
|
|
"darvaza.org/slog" |
|
|
|
"darvaza.org/slog" |
|
|
|
|
|
|
|
"github.com/spf13/cobra" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var log = zerolog.New(nil, slog.Error) |
|
|
|
|
|
|
|
|
|
|
|
// fatal is a convenience wrapper for slog.Logger.Fatal().Print()
|
|
|
|
// fatal is a convenience wrapper for slog.Logger.Fatal().Print()
|
|
|
|
func fatal(err error, msg string, args ...any) { |
|
|
|
func fatal(err error, msg string, args ...any) { |
|
|
|
l := log.Fatal() |
|
|
|
l := log.Fatal() |
|
|
@ -19,3 +23,20 @@ func fatal(err error, msg string, args ...any) { |
|
|
|
|
|
|
|
|
|
|
|
panic("unreachable") |
|
|
|
panic("unreachable") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var verbosity int |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// setVerbosity replaces the global logger using the
|
|
|
|
|
|
|
|
// verbosity level specified via -v flags
|
|
|
|
|
|
|
|
func setVerbosity(_ *cobra.Command, _ []string) { |
|
|
|
|
|
|
|
desired := int8(slog.Error) + int8(verbosity) |
|
|
|
|
|
|
|
if desired > 6 { |
|
|
|
|
|
|
|
desired = 6 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log = zerolog.New(nil, slog.LogLevel(desired)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
|
|
|
|
rootCmd.PersistentFlags().CountVarP(&verbosity, "verbosity", "v", |
|
|
|
|
|
|
|
"increase the verbosity level to Warn, Info or Debug") |
|
|
|
|
|
|
|
} |
|
|
|