File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,5 @@ require (
9
9
go.uber.org/multierr v1.1.0 // indirect
10
10
go.uber.org/zap v1.10.0
11
11
)
12
+
13
+ go 1.12
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ func init() {
22
22
23
23
// Logging environment variables
24
24
const (
25
+ // IPFS_* prefixed env vars kept for backwards compatibility
26
+ // for this release. They will not be available in the next
27
+ // release.
28
+ //
29
+ // GOLOG_* env vars take precedences over IPFS_* env vars.
30
+ envIPFSLogging = "IPFS_LOGGING"
31
+ envIPFSLoggingFmt = "IPFS_LOGGING_FMT"
32
+
25
33
envLogging = "GOLOG_LOG_LEVEL"
26
34
envLoggingFmt = "GOLOG_LOG_FMT"
27
35
@@ -44,9 +52,12 @@ var levels = make(map[string]zap.AtomicLevel)
44
52
var zapCfg = zap .NewProductionConfig ()
45
53
46
54
func SetupLogging () {
47
-
55
+ loggingFmt := os .Getenv (envLoggingFmt )
56
+ if loggingFmt == "" {
57
+ loggingFmt = os .Getenv (envIPFSLoggingFmt )
58
+ }
48
59
// colorful or plain
49
- switch os . Getenv ( envLoggingFmt ) {
60
+ switch loggingFmt {
50
61
case "nocolor" :
51
62
zapCfg .Encoding = "console"
52
63
zapCfg .EncoderConfig .EncodeLevel = zapcore .CapitalLevelEncoder
@@ -69,7 +80,12 @@ func SetupLogging() {
69
80
// set the backend(s)
70
81
lvl := LevelError
71
82
72
- if logenv := os .Getenv (envLogging ); logenv != "" {
83
+ logenv := os .Getenv (envLogging )
84
+ if logenv == "" {
85
+ logenv = os .Getenv (envIPFSLogging )
86
+ }
87
+
88
+ if logenv != "" {
73
89
var err error
74
90
lvl , err = LevelFromString (logenv )
75
91
if err != nil {
You can’t perform that action at this time.
0 commit comments