Merge pull request #327 from priyawadhwa/logs

Configure logs to show colors
This commit is contained in:
priyawadhwa
2018-08-29 17:39:40 -07:00
committed by GitHub
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -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 {
+5 -2
View File
@@ -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
}