-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption.go
More file actions
37 lines (31 loc) · 712 Bytes
/
option.go
File metadata and controls
37 lines (31 loc) · 712 Bytes
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
package log
import (
"os"
"strconv"
)
// Option provides the interface through which all loggers can be configured.
type Option interface {
Apply(l Logger) error
}
func boolFromEnv(env string, defaultValue bool) (bool, error) {
bo := defaultValue
if value, found := os.LookupEnv(env); found {
v, err := strconv.ParseBool(value)
if err != nil {
return bo, newEnvironmentConfigError(env, err)
}
bo = v
}
return bo, nil
}
var CommonOptions, _ = Options(
WithUTCTimestamp,
WithMicrosecondsTimestamp,
WithSourceLocationShort,
WithLevel(Debug),
WithPrintLevel(Info), // same level as the default for stdlog
WithStdlogHandler,
WithStdlogSorter(func(_ []byte) Level {
return Info
}),
)