forked from tormoder/fit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opts.go
49 lines (42 loc) · 1.24 KB
/
opts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package fit
import (
"log"
"os"
)
type decodeOptions struct {
logger Logger
unknownFields bool
unknownMessages bool
}
// DecodeOption configures a decoder.
type DecodeOption func(*decodeOptions)
// WithLogger configures the decoder to enable debug logging using the provided
// logger.
func WithLogger(logger Logger) DecodeOption {
return func(o *decodeOptions) {
o.logger = logger
}
}
// WithStdLogger configures the decoder to enable debug logging using the
// standard library's logger.
func WithStdLogger() DecodeOption {
return func(o *decodeOptions) {
o.logger = log.New(os.Stderr, "", 0)
}
}
// WithUnknownFields configures the decoder to record information about unknown
// fields encountered when decoding a known message type. Currently message
// number, field number and number of occurrences are recorded.
func WithUnknownFields() DecodeOption {
return func(o *decodeOptions) {
o.unknownFields = true
}
}
// WithUnknownMessages configures the decoder to record information about unknown
// messages encountered during decoding of a FIT file. Currently message
// number and number of occurrences are recorded.
func WithUnknownMessages() DecodeOption {
return func(o *decodeOptions) {
o.unknownMessages = true
}
}