add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
23
internal/infra/log/logger.go
Normal file
23
internal/infra/log/logger.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"epic-ent/internal/config"
|
||||
)
|
||||
|
||||
func NewLogger(cfg *config.Config) (*zap.Logger, error) {
|
||||
level := zapcore.InfoLevel
|
||||
if err := level.Set(cfg.Log.Level); err != nil {
|
||||
level = zapcore.InfoLevel
|
||||
}
|
||||
|
||||
zapCfg := zap.NewProductionConfig()
|
||||
zapCfg.Level = zap.NewAtomicLevelAt(level)
|
||||
if cfg.Log.Format == "console" {
|
||||
zapCfg.Encoding = "console"
|
||||
}
|
||||
|
||||
return zapCfg.Build()
|
||||
}
|
||||
Reference in New Issue
Block a user