-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduration.go
More file actions
30 lines (25 loc) · 1.13 KB
/
duration.go
File metadata and controls
30 lines (25 loc) · 1.13 KB
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
package sqlslog
type DurationType int
const (
DurationNanoSeconds DurationType = iota // Duration in nanoseconds. Durations in log are expressed by slog.Int64
DurationMicroSeconds // Duration in microseconds. Durations in log are expressed by slog.Int64
DurationMilliSeconds // Duration in milliseconds. Durations in log are expressed by slog.Int64
DurationGoDuration // Values in log are expressed with slog.Duration
DurationString // Values in log are expressed with slog.String and time.Duration.String
)
// Duration is an option to specify duration value in log.
// The default is DurationNanoSeconds.
func Duration(v DurationType) Option {
return func(o *options) {
o.stepLoggerOptions.durationType = v
}
}
// DurationKey is an option to specify the key for duration value in log.
// The default is specified by DurationKeyDefault.
func DurationKey(key string) Option {
return func(o *options) {
o.stepLoggerOptions.durationKey = key
}
}
// DurationKeyDefault is the default key for duration value in log.
const DurationKeyDefault = "duration"