-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
35 lines (29 loc) · 703 Bytes
/
Copy pathinit.go
File metadata and controls
35 lines (29 loc) · 703 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
package main
import (
"github.com/joho/godotenv"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func init() {
initLogger()
initEnviron()
}
func initLogger() {
// initialize logger
config := zap.NewProductionConfig()
config.Encoding = "console"
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
config.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder
config.OutputPaths = []string{"stdout"}
config.ErrorOutputPaths = []string{"stderr"}
logger, _ := config.Build()
zap.ReplaceGlobals(logger)
}
func initEnviron() {
// check .env file
if err := godotenv.Load(); err != nil {
zap.S().Warn("No .env file found")
} else {
zap.S().Info("Loaded .env file")
}
}