• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / go-tarantool / 22105359978

17 Feb 2026 03:51PM UTC coverage: 73.777% (-0.4%) from 74.209%
22105359978

Pull #518

github

babyTsakhes
test correct with message and return deleted code
Pull Request #518: conn: change design of tarantool.Logger

185 of 272 new or added lines in 3 files covered. (68.01%)

28 existing lines in 2 files now uncovered.

3123 of 4233 relevant lines covered (73.78%)

9475.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.43
/logger.go
1
package tarantool
2

3
import (
4
        "context"
5
        "log"
6
        "log/slog"
7
)
8

9
type Logger interface {
10
        Report(event LogEvent, conn *Connection)
11
}
12

13
type SlogLogger struct {
14
        logger *slog.Logger
15
        ctx    context.Context
16
}
17

18
func NewSlogLogger(logger *slog.Logger) SlogLogger {
347✔
19
        if logger == nil {
347✔
NEW
20
                logger = slog.Default()
×
NEW
21
        }
×
22
        return SlogLogger{
347✔
23
                logger: logger,
347✔
24
                ctx:    context.Background(),
347✔
25
        }
347✔
26
}
27

NEW
28
func (l *SlogLogger) WithContext(ctx context.Context) SlogLogger {
×
NEW
29
        return SlogLogger{
×
NEW
30
                logger: l.logger,
×
NEW
31
                ctx:    ctx,
×
NEW
32
        }
×
NEW
33
}
×
34

35
func (l SlogLogger) Report(event LogEvent, conn *Connection) {
783✔
36
        attrs := event.LogAttrs()
783✔
37

783✔
38
        if conn != nil {
1,566✔
39
                keys := make(map[string]bool, len(attrs))
783✔
40
                for _, a := range attrs {
4,619✔
41
                        keys[a.Key] = true
3,836✔
42
                }
3,836✔
43

44
                if !keys["connection_state"] {
1,566✔
45
                        attrs = append(attrs, slog.String("connection_state", conn.stateToString()))
783✔
46
                }
783✔
47

48
                if conn.opts.MaxReconnects > 0 && !keys["max_reconnects"] {
1,062✔
49
                        attrs = append(attrs, slog.Uint64("max_reconnects", uint64(conn.opts.MaxReconnects)))
279✔
50
                }
279✔
51
                if conn.opts.Reconnect > 0 && !keys["reconnect_interval"] {
1,150✔
52
                        attrs = append(attrs, slog.String("reconnect_interval", conn.opts.Reconnect.String()))
367✔
53
                }
367✔
54
                if conn.opts.Timeout > 0 && !keys["request_timeout"] {
1,565✔
55
                        attrs = append(attrs, slog.String("request_timeout", conn.opts.Timeout.String()))
782✔
56
                }
782✔
57
        }
58

59
        l.logger.LogAttrs(l.ctx, event.LogLevel(), event.Message(), attrs...)
783✔
60
}
61

62
type SimpleLogger struct{}
63

64
func (l SimpleLogger) Report(event LogEvent, conn *Connection) {
4✔
65
        attrs := event.LogAttrs()
4✔
66

4✔
67
        log.Printf("[%s] %s [event=%s]", event.LogLevel(), event.Message(), event.EventName())
4✔
68

4✔
69
        for _, attr := range attrs {
23✔
70
                if attr.Key == "error" {
19✔
NEW
71
                        log.Printf("  Error: %v", attr.Value.Any())
×
72
                } else if attr.Key == "request_id" {
21✔
73
                        log.Printf("  Request ID: %v", attr.Value.Any())
2✔
74
                }
2✔
75
        }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc