Skip to content

Commit

Permalink
Merge pull request #7 from lelvisl/6
Browse files Browse the repository at this point in the history
Fix 6
  • Loading branch information
lelvisl authored Mar 18, 2019
2 parents 6cd87c6 + 0044b1c commit ed73ac5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ type LogConfig struct {
type SentryConfig struct {
Tags map[string]string `yaml:"tags" json:"tags"`
DSN string `yaml:"dsn" json:"dns"`

StacktraceConfigurationEnable bool `yaml:"stacktrace_enable" json:"stacktrace_enable"`
// the number of lines to include around a stack frame for context.
StacktraceConfigurationContext int `yaml:"stacktrace_context" json:"stacktrace_context"`
// whether to create a breadcrumb with the full text of error
StacktraceConfigurationBreadcrumb bool `yam:"stacktrace_breadcrumb" json:"stacktrace_breadcrumb"`
// the logrus level at which to start capturing stacktraces.
StacktraceConfigurationLevel log.Level `yaml:"stacktrace_level" json:"stacktrace_level"`
}

type ctxlog struct{}
Expand Down
5 changes: 5 additions & 0 deletions logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func TestCreateLogger(t *testing.T) {
"Warn text",
"LOG_WARNING",
},
{
"Err text",
"LOG_ERR",
},
{
"Debug text",
"LOG_DEBUG",
Expand All @@ -42,6 +46,7 @@ func TestCreateLogger(t *testing.T) {

logger.Infoln(tc.LogLevel, "Info text")
logger.Warningln(tc.LogLevel, " Warn text")
logger.Errorln(tc.LogLevel, "Err text")
logger.Debugln(tc.LogLevel, "Debug text")
}
}
4 changes: 4 additions & 0 deletions sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func sentryHook(config *LogConfig) (*logrus_sentry.SentryHook, error) {
}

hook, err = logrus_sentry.NewWithClientSentryHook(client, levels)
hook.StacktraceConfiguration.Enable = config.Sentry.StacktraceConfigurationEnable
hook.StacktraceConfiguration.Level = config.Sentry.StacktraceConfigurationLevel
hook.StacktraceConfiguration.Context = config.Sentry.StacktraceConfigurationContext
hook.StacktraceConfiguration.IncludeErrorBreadcrumb = config.Sentry.StacktraceConfigurationBreadcrumb

return hook, err
}

0 comments on commit ed73ac5

Please sign in to comment.