diff --git a/commands/root.go b/commands/root.go index c5f03097f2a..bed7dece02d 100644 --- a/commands/root.go +++ b/commands/root.go @@ -28,6 +28,8 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman } } + logrus.SetFormatter(&logutil.Formatter{}) + logrus.AddHook(logutil.NewFilter([]logrus.Level{ logrus.DebugLevel, }, diff --git a/util/logutil/format.go b/util/logutil/format.go new file mode 100644 index 00000000000..fcd7320877c --- /dev/null +++ b/util/logutil/format.go @@ -0,0 +1,16 @@ +package logutil + +import ( + "fmt" + "strings" + + "github.com/sirupsen/logrus" +) + +type Formatter struct { + logrus.TextFormatter +} + +func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error) { + return []byte(fmt.Sprintf("%s: %s\n", strings.ToUpper(entry.Level.String()), entry.Message)), nil +}