Skip to content

Commit

Permalink
only init sentry once
Browse files Browse the repository at this point in the history
  • Loading branch information
lyoshenka committed Apr 21, 2020
1 parent bf40725 commit 4d95fef
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ var textFormatter = logrus.TextFormatter{FullTimestamp: true, TimestampFormat: "
// init magic is needed so logging is set up without calling it in every package explicitly
func init() {
configureLogger(logrus.StandardLogger())
configureSentry(version.GetDevVersion(), mode())
}

func mode() string {
if config.IsProduction() {
return "production"
} else {
return "develop"
}
}

// configureLogger sets a few parameters for the logging subsystem.
func configureLogger(l *logrus.Logger) {
var mode string

if config.IsProduction() {
mode = "production"

l.SetLevel(logrus.InfoLevel)
l.SetFormatter(&jsonFormatter)
} else {
mode = "develop"

l.SetLevel(logrus.TraceLevel)
l.SetFormatter(&textFormatter)
}

l.Infof("%s, running in %s mode", version.GetFullBuildName(), mode)
l.Infof("logging initialized (loglevel=%s)", l.Level)

configureSentry(version.GetDevVersion(), mode)
l.Infof("%%s mode, %s level, %s", version.GetFullBuildName(), l.Level, mode())
}

// LogSuccessfulQuery takes a remote method name, execution time and params and logs it
Expand Down

0 comments on commit 4d95fef

Please sign in to comment.