mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(log): replace standard logger with zerolog
- Integrate `rs/zerolog` for structured and leveled logging - Add `EZ_LOG_LEVEL` environment variable support (default: info) - Configure console output with timestamps and service fields - Migrate `main.go` and `LogWriter` to use the new logger instance - Update README with logging configuration and design details
This commit is contained in:
@@ -2,10 +2,10 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"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.Printf("log batch insert failed: %v", err)
|
||||
log.Error().Err(err).Msg("log batch insert failed")
|
||||
}
|
||||
buf = buf[:0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user