sco/bot/logger.go
sneak 98e9eb44d3
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
maybe works now
2020-09-08 21:15:50 -07:00

40 lines
709 B
Go

package bot
import (
"os"
"time"
"github.com/mattn/go-isatty"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func (b *Bot) setupLogging() {
log.Logger = log.With().Caller().Logger()
tty := isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd())
if tty {
out := zerolog.NewConsoleWriter(
func(w *zerolog.ConsoleWriter) {
// Customize time format
w.TimeFormat = time.RFC3339
},
)
log.Logger = log.Output(out)
}
// always log in UTC
zerolog.TimestampFunc = func() time.Time {
return time.Now().UTC()
}
zerolog.SetGlobalLevel(zerolog.DebugLevel)
//zerolog.SetGlobalLevel(zerolog.InfoLevel)
//if viper.GetBool("debug") {
//}
b.identify()
}