Skip to content

Commit

Permalink
Added sentry support
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed May 14, 2015
1 parent 207bc2f commit d58d5ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 7 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ type Config struct {
EnableHealthChecks bool `json:"enable_health_checks"`
HealthCheckValueTimeout int64 `json:"health_check_value_timeouts"`
} `json:"health_check"`
UseAsyncSessionWrite bool `json:"optimisations_use_async_session_write"`
AllowMasterKeys bool `json:"allow_master_keys"`
HashKeys bool `json:"hash_keys"`
SuppressRedisSignalReload bool `json:"suppress_redis_signal_reload"`
SupressDefaultOrgStore bool `json:"suppress_default_org_store"`
UseAsyncSessionWrite bool `json:"optimisations_use_async_session_write"`
AllowMasterKeys bool `json:"allow_master_keys"`
HashKeys bool `json:"hash_keys"`
SuppressRedisSignalReload bool `json:"suppress_redis_signal_reload"`
SupressDefaultOrgStore bool `json:"suppress_default_org_store"`
SentryCode string `json:"sentry_code"`
UseSentry bool `json:"use_sentry"`
}

// WriteDefaultConf will create a default configuration file and set the storage type to "memory"
Expand Down
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/Sirupsen/logrus/hooks/sentry"
"github.com/docopt/docopt.go"
"github.com/justinas/alice"
osin "github.com/lonelycode/osin"
Expand Down Expand Up @@ -512,6 +513,20 @@ func init() {
log.Debug("Enabling debug-level output")
}

if config.UseSentry {
log.Info("Enabling Sentry support")
hook, err := logrus_sentry.NewSentryHook(config.SentryCode, []logrus.Level{
logrus.PanicLevel,
logrus.FatalLevel,
logrus.ErrorLevel,
})

if err == nil {
log.Hooks.Add(hook)
}
log.Info("Sentry hook active")
}

}

func main() {
Expand Down

0 comments on commit d58d5ed

Please sign in to comment.