Skip to content

Commit 370cc50

Browse files
authored
config inspection (#129)
1 parent 358e037 commit 370cc50

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

setup.go

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"go.uber.org/zap/zapcore"
1414
)
1515

16+
var config Config
17+
1618
func init() {
1719
SetupLogging(configFromEnv())
1820
}
@@ -92,6 +94,12 @@ var primaryCore zapcore.Core
9294
// loggerCore is the base for all loggers created by this package
9395
var loggerCore = &lockedMultiCore{}
9496

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+
95103
// SetupLogging will initialize the logger backend and set the flags.
96104
// TODO calling this in `init` pushes all configuration to env variables
97105
// - 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) {
100108
loggerMutex.Lock()
101109
defer loggerMutex.Unlock()
102110

111+
config = cfg
112+
103113
primaryFormat = cfg.Format
104114
defaultLevel = cfg.Level
105115

0 commit comments

Comments
 (0)