mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-26 15:53:42 +00:00
This pulls in another slew of other packages. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
33 lines
955 B
Go
33 lines
955 B
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/pflag"
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
logutil "github.com/docker/infrakit/pkg/log"
|
|
)
|
|
|
|
// DefaultLogLevel is the default log level value.
|
|
var DefaultLogLevel = len(logrus.AllLevels) - 2
|
|
|
|
// SetLogLevel adjusts the logrus level.
|
|
func SetLogLevel(level int) {
|
|
if level > len(logrus.AllLevels)-1 {
|
|
level = len(logrus.AllLevels) - 1
|
|
} else if level < 0 {
|
|
level = 0
|
|
}
|
|
logrus.SetLevel(logrus.AllLevels[level])
|
|
}
|
|
|
|
// Flags returns the set of logging flags
|
|
func Flags(o *logutil.Options) *pflag.FlagSet {
|
|
f := pflag.NewFlagSet("logging", pflag.ExitOnError)
|
|
f.IntVar(&o.Level, "log", o.Level, "log level")
|
|
f.BoolVar(&o.Stdout, "log-stdout", o.Stdout, "log to stdout")
|
|
f.BoolVar(&o.CallFunc, "log-caller", o.CallFunc, "include caller function")
|
|
f.BoolVar(&o.CallStack, "log-stack", o.CallStack, "include caller stack")
|
|
f.StringVar(&o.Format, "log-format", o.Format, "log format: logfmt|term|json")
|
|
return f
|
|
}
|