28 lines
532 B
Go
28 lines
532 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var verbose bool
|
|
|
|
type PlainFormatter struct {
|
|
}
|
|
|
|
func (f *PlainFormatter) Format(entry *log.Entry) ([]byte, error) {
|
|
return []byte(fmt.Sprintf("%s\n", entry.Message)), nil
|
|
}
|
|
func toggleDebug(cmd *cobra.Command, args []string) {
|
|
if verbose {
|
|
log.Info("Debug logs enabled")
|
|
log.SetLevel(log.DebugLevel)
|
|
log.SetFormatter(&log.TextFormatter{})
|
|
} else {
|
|
plainFormatter := new(PlainFormatter)
|
|
log.SetFormatter(plainFormatter)
|
|
}
|
|
}
|