refactor(log): migrate from zerolog to structured slog with bridge

- Replace direct zerolog usage with standard library `log/slog` in business code
- Add `internal/logging` package with zerolog bridge handler for structured output
- Create `internal/jsoncodec` package to centralize JSON encoding/decoding using Sonic
- Update all services and main entry point to use new logging interface
- Maintain backward compatibility with existing zerolog console output
- Remove custom logger setup in favor of structured logging bridge
This commit is contained in:
zenfun
2025-12-13 16:50:56 +08:00
parent 305f2ebf18
commit 89cb74ba6e
7 changed files with 248 additions and 48 deletions

View File

@@ -2,10 +2,10 @@ package service
import (
"context"
"log/slog"
"time"
"github.com/ez-api/ez-api/internal/model"
"github.com/rs/zerolog/log"
"gorm.io/gorm"
)
@@ -47,7 +47,7 @@ func (w *LogWriter) Start(ctx context.Context) {
return
}
if err := w.db.Create(&buf).Error; err != nil {
log.Error().Err(err).Msg("log batch insert failed")
slog.Default().Error("log batch insert failed", "err", err)
}
buf = buf[:0]
}