File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -26,33 +26,38 @@ func SetupLog(l string) error {
26
26
return nil
27
27
}
28
28
29
- // Fields is identical to logrus.Fields
30
- type Fields log.Fields
29
+ // Fields is a wrapper for logrus.Entry
30
+ // we need to insert some sentry captures here
31
+ type Fields struct {
32
+ e * log.Entry
33
+ }
31
34
32
35
// WithField .
33
36
func (f Fields ) WithField (key string , value interface {}) Fields {
34
- f [ key ] = value
35
- return f
37
+ e := f . e . WithField ( key , value )
38
+ return Fields { e : e }
36
39
}
37
40
38
41
// Errorf sends sentry message
39
42
func (f Fields ) Errorf (format string , args ... interface {}) {
40
43
sentry .CaptureMessage (fmt .Sprintf (format , args ... ))
41
- log . WithFields ( log . Fields ( f )) .Errorf (format , args ... )
44
+ f . e .Errorf (format , args ... )
42
45
}
43
46
44
47
// Err is a decorator returning the argument
45
48
func (f Fields ) Err (err error ) error {
46
49
if err != nil {
47
50
sentry .CaptureMessage (fmt .Sprintf ("%+v" , err ))
48
- log . WithFields ( log . Fields ( f )) .Errorf ("%+v" , err )
51
+ f . e .Errorf ("%+v" , err )
49
52
}
50
53
return err
51
54
}
52
55
53
56
// WithField add kv into log entry
54
57
func WithField (key string , value interface {}) Fields {
55
- return Fields {key : value }
58
+ return Fields {
59
+ e : log .WithField (key , value ),
60
+ }
56
61
}
57
62
58
63
// Error forwards to sentry
You can’t perform that action at this time.
0 commit comments