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

echocat / slf4g / 18165971281

01 Oct 2025 02:44PM UTC coverage: 97.558% (-0.1%) from 97.667%
18165971281

Pull #52

github

web-flow
Merge ad46253f5 into f483a0939
Pull Request #52: Added log/slog implementation

359 of 381 new or added lines in 15 files covered. (94.23%)

4474 of 4586 relevant lines covered (97.56%)

121.84 hits per line

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

90.67
/testing/recording/event.go
1
package recording
2

3
import (
4
        "fmt"
5

6
        log "github.com/echocat/slf4g"
7
        "github.com/echocat/slf4g/fields"
8
        "github.com/echocat/slf4g/level"
9
)
10

11
type event struct {
12
        provider log.Provider
13
        fields   fields.Fields
14
        level    level.Level
15
}
16

17
func (instance *event) ForEach(consumer func(key string, value interface{}) error) error {
280✔
18
        return instance.fields.ForEach(consumer)
280✔
19
}
280✔
20

21
func (instance *event) Get(key string) (interface{}, bool) {
1,520✔
22
        return instance.fields.Get(key)
1,520✔
23
}
1,520✔
24

25
func (instance *event) Len() int {
590✔
26
        return instance.fields.Len()
590✔
27
}
590✔
28

29
func (instance *event) GetLevel() level.Level {
1,230✔
30
        return instance.level
1,230✔
31
}
1,230✔
32

33
func (instance *event) With(key string, value interface{}) log.Event {
2,050✔
34
        return instance.with(func(s fields.Fields) fields.Fields {
4,100✔
35
                return s.With(key, value)
2,050✔
36
        })
2,050✔
37
}
38

39
func (instance *event) Withf(key string, format string, args ...interface{}) log.Event {
10✔
40
        return instance.with(func(s fields.Fields) fields.Fields {
20✔
41
                return s.Withf(key, format, args...)
10✔
42
        })
10✔
43
}
44

45
func (instance *event) WithError(err error) log.Event {
10✔
46
        return instance.with(func(s fields.Fields) fields.Fields {
20✔
47
                return s.With(instance.provider.GetFieldKeysSpec().GetError(), err)
10✔
48
        })
10✔
49
}
50

51
func (instance *event) WithAll(of map[string]interface{}) log.Event {
10✔
52
        return instance.with(func(s fields.Fields) fields.Fields {
20✔
53
                return s.WithAll(of)
10✔
54
        })
10✔
55
}
56

57
func (instance *event) Without(keys ...string) log.Event {
750✔
58
        return instance.with(func(s fields.Fields) fields.Fields {
1,500✔
59
                return s.Without(keys...)
750✔
60
        })
750✔
61
}
62

63
func (instance *event) with(mod func(fields.Fields) fields.Fields) log.Event {
2,830✔
64
        return &event{
2,830✔
65
                provider: instance.provider,
2,830✔
66
                fields:   mod(instance.fields),
2,830✔
67
                level:    instance.level,
2,830✔
68
        }
2,830✔
69
}
2,830✔
70

71
func (instance *event) Format(f fmt.State, verb rune) {
40✔
72
        printf := func(format string, args ...interface{}) {
250✔
73
                _, _ = fmt.Fprintf(f, format, args...)
210✔
74
        }
210✔
75

76
        switch verb {
40✔
77
        case 'v':
40✔
78
                fds := instance.fields
40✔
79
                if f.Flag('+') && fds != nil && fds.Len() > 0 {
50✔
80
                        printf("[%d] {", instance.level)
10✔
81
                        _ = fds.ForEach(func(key string, value interface{}) error {
50✔
82
                                if key == "logger" || key == "timestamp" {
40✔
NEW
83
                                        return nil
×
NEW
84
                                }
×
85
                                printf("\n\t%s=%+v", key, value)
40✔
86
                                return nil
40✔
87
                        })
88
                        printf("\n}")
10✔
89
                } else {
30✔
90
                        printf("[%d] {", instance.level)
30✔
91
                        first := true
30✔
92
                        _ = fds.ForEach(func(key string, value interface{}) error {
130✔
93
                                if key == "logger" || key == "timestamp" {
140✔
94
                                        return nil
40✔
95
                                }
40✔
96
                                if first {
90✔
97
                                        first = false
30✔
98
                                } else {
60✔
99
                                        printf(", ")
30✔
100
                                }
30✔
101
                                printf("%s=%v", key, value)
60✔
102
                                return nil
60✔
103
                        })
104
                        printf("}")
30✔
105
                }
NEW
106
        default:
×
NEW
107
                printf("%%!%c(*types.Sym=%p)", verb, instance)
×
108
        }
109
}
110

NEW
111
func (instance *event) String() string {
×
NEW
112
        return fmt.Sprintf("%v", instance)
×
NEW
113
}
×
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

© 2025 Coveralls, Inc