diff --git a/logger.go b/logger.go index c8adf22..c903584 100644 --- a/logger.go +++ b/logger.go @@ -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{} diff --git a/logger_test.go b/logger_test.go index 8c79667..e58f2e3 100644 --- a/logger_test.go +++ b/logger_test.go @@ -20,6 +20,10 @@ func TestCreateLogger(t *testing.T) { "Warn text", "LOG_WARNING", }, + { + "Err text", + "LOG_ERR", + }, { "Debug text", "LOG_DEBUG", @@ -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") } } diff --git a/sentry.go b/sentry.go index d05338a..0abb6c5 100644 --- a/sentry.go +++ b/sentry.go @@ -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 }