add initial application structure with configuration, logging, and health check endpoints

This commit is contained in:
kever
2026-01-15 22:48:28 +08:00
parent fe67f09e72
commit 2efefc7e05
24 changed files with 178 additions and 83 deletions

View File

@@ -15,9 +15,21 @@ func NewLogger(cfg *config.Config) (*zap.Logger, error) {
zapCfg := zap.NewProductionConfig()
zapCfg.Level = zap.NewAtomicLevelAt(level)
zapCfg.EncoderConfig.CallerKey = "caller"
zapCfg.EncoderConfig.StacktraceKey = "stacktrace"
if cfg.Log.Format == "console" {
zapCfg.Encoding = "console"
devCfg := zap.NewDevelopmentConfig()
devCfg.Level = zap.NewAtomicLevelAt(level)
devCfg.EncoderConfig.CallerKey = "caller"
devCfg.EncoderConfig.StacktraceKey = "stacktrace"
return devCfg.Build(
zap.AddCaller(),
zap.AddStacktrace(zapcore.ErrorLevel),
)
}
return zapCfg.Build()
return zapCfg.Build(
zap.AddCaller(),
zap.AddStacktrace(zapcore.ErrorLevel),
)
}