Tool to help you manage your Grafana dashboards using Git.

logger.go 699B

123456789101112131415161718192021222324252627282930
  1. package logger
  2. import (
  3. "github.com/sirupsen/logrus"
  4. )
  5. // utcFormatter is a custom logrus formatter that converts the time for all
  6. // entries to UTC.
  7. type utcFormatter struct {
  8. logrus.Formatter
  9. }
  10. // Format implements logrus.Formatter.Format().
  11. func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) {
  12. entry.Time = entry.Time.UTC()
  13. return f.Formatter.Format(entry)
  14. }
  15. // LogConfig sets the format of the default logger.
  16. func LogConfig() {
  17. logrus.SetFormatter(&utcFormatter{
  18. &logrus.TextFormatter{
  19. TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
  20. FullTimestamp: true,
  21. DisableColors: false,
  22. DisableTimestamp: false,
  23. DisableSorting: false,
  24. },
  25. })
  26. }