Commit
This commit is contained in:
25
initialize/logger.go
Normal file
25
initialize/logger.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"nCovTrack-Backend/global"
|
||||
"nCovTrack-Backend/utils"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func initLogger() {
|
||||
zapConfig := zap.NewProductionConfig()
|
||||
zapConfig.OutputPaths = []string{
|
||||
fmt.Sprintf("%slog_%s.log", global.ServerSettings.LogPath, utils.FormateDate(time.Now())),
|
||||
"stdout",
|
||||
}
|
||||
logger, err := zapConfig.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sLogger := logger.Sugar()
|
||||
zap.ReplaceGlobals(sLogger.Desugar())
|
||||
global.Logger = sLogger
|
||||
}
|
||||
Reference in New Issue
Block a user