@@ -33,6 +33,43 @@ func (s *slogSentryBreadcrumbs) Enabled(context.Context, slog.Level) bool {
33
33
return true
34
34
}
35
35
36
+ func (s * slogSentryBreadcrumbs ) parseAttributeValue (a slog.Attr ) (key string , value any ) {
37
+ key = a .Key
38
+
39
+ switch a .Value .Kind () {
40
+ case slog .KindAny :
41
+ value = a .Value .Any ()
42
+ case slog .KindBool :
43
+ value = a .Value .Bool ()
44
+ case slog .KindDuration :
45
+ value = a .Value .Duration ().String ()
46
+ case slog .KindFloat64 :
47
+ value = a .Value .Float64 ()
48
+ case slog .KindInt64 :
49
+ value = a .Value .Int64 ()
50
+ case slog .KindString :
51
+ value = a .Value .String ()
52
+ case slog .KindTime :
53
+ value = a .Value .Time ().String ()
54
+ case slog .KindUint64 :
55
+ value = a .Value .Uint64 ()
56
+ case slog .KindGroup :
57
+ m := make (map [string ]any )
58
+ group := a .Value .Group ()
59
+ for _ , b := range group {
60
+ k , v := s .parseAttributeValue (b )
61
+ m [k ] = v
62
+ }
63
+
64
+ value = m
65
+ case slog .KindLogValuer :
66
+ valuer := a .Value .LogValuer ()
67
+ b := slog .Any (a .Key , valuer )
68
+ _ , value = s .parseAttributeValue (b )
69
+ }
70
+ return
71
+ }
72
+
36
73
// Handle implements slog.Handler.
37
74
func (s * slogSentryBreadcrumbs ) Handle (ctx context.Context , r slog.Record ) error {
38
75
if ctx == nil {
@@ -51,7 +88,8 @@ func (s *slogSentryBreadcrumbs) Handle(ctx context.Context, r slog.Record) error
51
88
52
89
var data = make (map [string ]any )
53
90
r .Attrs (func (a slog.Attr ) bool {
54
- data [a .Key ] = a .Value
91
+ key , value := s .parseAttributeValue (a )
92
+ data [key ] = value
55
93
return true
56
94
})
57
95
0 commit comments