Commit 370cc50 1 parent 358e037 commit 370cc50 Copy full SHA for 370cc50
File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import (
13
13
"go.uber.org/zap/zapcore"
14
14
)
15
15
16
+ var config Config
17
+
16
18
func init () {
17
19
SetupLogging (configFromEnv ())
18
20
}
@@ -92,6 +94,12 @@ var primaryCore zapcore.Core
92
94
// loggerCore is the base for all loggers created by this package
93
95
var loggerCore = & lockedMultiCore {}
94
96
97
+ // GetConfig returns a copy of the saved config. It can be inspected, modified,
98
+ // and re-applied using a subsequent call to SetupLogging().
99
+ func GetConfig () Config {
100
+ return config
101
+ }
102
+
95
103
// SetupLogging will initialize the logger backend and set the flags.
96
104
// TODO calling this in `init` pushes all configuration to env variables
97
105
// - move it out of `init`? then we need to change all the code (js-ipfs, go-ipfs) to call this explicitly
@@ -100,6 +108,8 @@ func SetupLogging(cfg Config) {
100
108
loggerMutex .Lock ()
101
109
defer loggerMutex .Unlock ()
102
110
111
+ config = cfg
112
+
103
113
primaryFormat = cfg .Format
104
114
defaultLevel = cfg .Level
105
115
You can’t perform that action at this time.
0 commit comments