-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
43 lines (38 loc) · 1.04 KB
/
Copy pathinit.go
File metadata and controls
43 lines (38 loc) · 1.04 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
31
32
33
34
35
36
37
38
39
40
41
42
43
package kboot
import (
"context"
"sync"
"github.com/guestin/log"
"github.com/spf13/viper"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var _initOnce = &sync.Once{}
func init() {
// init logger
lv, err := zapcore.ParseLevel(DefaultLogLevel)
if err != nil {
panic(err)
}
rootLogger, _ := log.EasyInitConsoleLogger(lv, zap.ErrorLevel)
_initOnce.Do(func() {
_gCtx = &_ctx{
ctx: context.Background(),
viper: viper.New(),
logLevel: DefaultLogLevel,
hideBanner: false,
rootLogger: rootLogger,
logger: log.NewTaggedZapLogger(rootLogger, LoggerTag),
units: make([]*unitImpl, 0),
configName: DefaultConfigName,
configFileType: "",
configSearchPaths: []string{DefaultConfigFilePath},
configFile: "",
configData: nil,
enableEnvOverride: true,
envPrefix: DefaultConfigEnvPrefix,
}
_gCtx.viper.SetDefault(CfgKeyAppTz, DefaultAppTz.String())
_gCtx.viper.SetDefault(CfgKeyAppLogLevel, DefaultLogLevel)
})
}