slaventius 2 years ago
parent ac0be38b33
commit ce6d910012
  1. 18
      pkg/logger/logger.go

@ -10,12 +10,20 @@ import (
type Logger struct {
*logrus.Logger
tags map[string]string
}
func NewLogger(appSource string, dsn string) *Logger {
logger := logrus.New()
logger.SetReportCaller(true) // Добавим отображение строки
//
lo := Logger{
Logger: logger,
tags: make(map[string]string),
}
lo.tags["app"] = appSource
//
if dsn == "" {
logger.Warn("sentry dsn is empty, its use is not possible")
@ -29,19 +37,13 @@ func NewLogger(appSource string, dsn string) *Logger {
}); err != nil {
log.Fatal(err)
} else {
//
tags := make(map[string]string)
tags["app"] = appSource
hook.Timeout = 1 * time.Second
hook.SetTagsContext(tags)
hook.SetTagsContext(lo.tags)
//
logger.Hooks.Add(hook)
}
}
return &Logger{
Logger: logger,
}
return &lo
}

Loading…
Cancel
Save