Configure logs to show colors
This commit is contained in:
parent
49f92980d5
commit
15db85e36a
|
|
@ -48,7 +48,7 @@ func init() {
|
||||||
var RootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
Use: "executor",
|
Use: "executor",
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if err := util.SetLogLevel(logLevel); err != nil {
|
if err := util.ConfigureLogging(logLevel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !opts.NoPush && len(opts.Destinations) == 0 {
|
if !opts.NoPush && len(opts.Destinations) == 0 {
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,16 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetLogLevel sets the logrus logging level
|
// ConfigureLogging sets the logrus logging level and forces logs to be colorful (!)
|
||||||
func SetLogLevel(logLevel string) error {
|
func ConfigureLogging(logLevel string) error {
|
||||||
lvl, err := logrus.ParseLevel(logLevel)
|
lvl, err := logrus.ParseLevel(logLevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "parsing log level")
|
return errors.Wrap(err, "parsing log level")
|
||||||
}
|
}
|
||||||
logrus.SetLevel(lvl)
|
logrus.SetLevel(lvl)
|
||||||
|
logrus.SetFormatter(&logrus.TextFormatter{
|
||||||
|
ForceColors: true,
|
||||||
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue