Remove sentry and error reporting

This commit is contained in:
Jamie Curnow
2023-07-20 15:19:42 +10:00
parent 6d6021c9bb
commit fd7095ad88
18 changed files with 26 additions and 144 deletions

View File

@ -1,7 +1,5 @@
package logger
import "github.com/getsentry/sentry-go"
// Level type
type Level int
@ -21,7 +19,6 @@ const (
type Config struct {
LogThreshold Level
Formatter string
SentryConfig sentry.ClientOptions
}
// Interface for a logger

View File

@ -10,7 +10,6 @@ import (
"time"
"github.com/fatih/color"
"github.com/getsentry/sentry-go"
"github.com/rotisserie/eris"
)
@ -113,13 +112,6 @@ func (l *Logger) Configure(c *Config) error {
l.LogThreshold = c.LogThreshold
l.Formatter = c.Formatter
l.SentryConfig = c.SentryConfig
if c.SentryConfig.Dsn != "" {
if sentryErr := sentry.Init(c.SentryConfig); sentryErr != nil {
fmt.Printf("Sentry initialization failed: %v\n", sentryErr)
}
}
stdlog.SetFlags(0) // this removes timestamp prefixes from logs
return nil
@ -228,21 +220,4 @@ func (l *Logger) Warn(format string, args ...interface{}) {
// Attempts to log to bugsang.
func (l *Logger) Error(errorClass string, err error) {
l.logLevel(ErrorLevel, err.Error(), errorClass)
l.notifySentry(errorClass, err)
}
func (l *Logger) notifySentry(errorClass string, err error) {
if l.SentryConfig.Dsn != "" && l.SentryConfig.Dsn != "-" {
sentry.ConfigureScope(func(scope *sentry.Scope) {
scope.SetLevel(sentry.LevelError)
scope.SetTag("service", "backend")
scope.SetTag("error_class", errorClass)
})
sentry.CaptureException(err)
// Since sentry emits events in the background we need to make sure
// they are sent before we shut down
sentry.Flush(time.Second * 5)
}
}

View File

@ -7,7 +7,6 @@ import (
"os"
"testing"
"github.com/getsentry/sentry-go"
"github.com/rotisserie/eris"
"github.com/stretchr/testify/assert"
)
@ -115,7 +114,6 @@ func TestConfigure(t *testing.T) {
args: args{
&Config{
LogThreshold: InfoLevel,
SentryConfig: sentry.ClientOptions{},
},
},
wantErr: false,
@ -123,9 +121,7 @@ func TestConfigure(t *testing.T) {
{
name: "invalid log level",
args: args{
&Config{
SentryConfig: sentry.ClientOptions{},
},
&Config{},
},
wantErr: true,
},