Skip to content

Commit

Permalink
Merge pull request #327 from priyawadhwa/logs
Browse files Browse the repository at this point in the history
Configure logs to show colors
  • Loading branch information
priyawadhwa authored Aug 30, 2018
2 parents 7646817 + 15db85e commit bb75c04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/executor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func init() {
var RootCmd = &cobra.Command{
Use: "executor",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if err := util.SetLogLevel(logLevel); err != nil {
if err := util.ConfigureLogging(logLevel); err != nil {
return err
}
if !opts.NoPush && len(opts.Destinations) == 0 {
Expand Down
7 changes: 5 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ import (
"github.com/sirupsen/logrus"
)

// SetLogLevel sets the logrus logging level
func SetLogLevel(logLevel string) error {
// ConfigureLogging sets the logrus logging level and forces logs to be colorful (!)
func ConfigureLogging(logLevel string) error {
lvl, err := logrus.ParseLevel(logLevel)
if err != nil {
return errors.Wrap(err, "parsing log level")
}
logrus.SetLevel(lvl)
logrus.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
})
return nil
}

Expand Down

0 comments on commit bb75c04

Please sign in to comment.