Add structured logging and centralized error handling
- Initialize slog in the serve command with terminal/file support - Introduce `AppError` with HTTP status for unified service-layer errors - Replace ad-hoc `api.Error` calls with `api.RespondError` - Wrap internal errors with `model.NewInternalError` and add reference IDs - Add `RequestID` middleware and switch router from `gin.Default` to `gin.New`
This commit is contained in:
@@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
@@ -56,7 +57,7 @@ func Bootstrap(cfg *config.Config) (*WebApp, error) {
|
||||
return nil, fmt.Errorf("init storage: %w", err)
|
||||
}
|
||||
|
||||
fileService := service.NewFileService(fileRepo, store, cfg.Storage.MaxUploadSize)
|
||||
fileService := service.NewFileService(fileRepo, store, cfg.Storage.MaxUploadSize, slog.Default())
|
||||
|
||||
return &WebApp{
|
||||
Config: cfg,
|
||||
|
||||
Reference in New Issue
Block a user