grim/hgkeeper

logrus: disable colors if term is "dumb"
termdumb
2019-04-18, Wagner Riffel
f5cf0e9c5831
logrus: disable colors if term is "dumb"
  • +9 -2
    main.go
  • --- a/main.go Wed Apr 17 18:04:18 2019 -0500
    +++ b/main.go Thu Apr 18 01:17:59 2019 -0300
    @@ -19,9 +19,16 @@
    func init() {
    log.SetOutput(os.Stdout)
    log.SetLevel(log.DebugLevel)
    - log.SetFormatter(&log.TextFormatter{
    + fmter := &log.TextFormatter{
    FullTimestamp: true,
    - })
    + }
    + switch os.Getenv("TERM") {
    + case "win":
    + fallthrough
    + case "dumb":
    + fmter.DisableColors = true
    + }
    + log.SetFormatter(fmter)
    }
    func main() {