refactor: rename internal/log to internal/logging to avoid stdlib
shadowing - refactor: rename `internal/log` → `internal/logging`, package `log` → `logging` - refactor: update imports in `cmd/serve.go` and `internal/middleware/requestid.go`
This commit is contained in:
+2
-2
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/dhao2001/mygo/internal/app"
|
"github.com/dhao2001/mygo/internal/app"
|
||||||
"github.com/dhao2001/mygo/internal/config"
|
"github.com/dhao2001/mygo/internal/config"
|
||||||
mygolog "github.com/dhao2001/mygo/internal/log"
|
"github.com/dhao2001/mygo/internal/logging"
|
||||||
"github.com/dhao2001/mygo/internal/server"
|
"github.com/dhao2001/mygo/internal/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ var serveCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up structured logging before anything else.
|
// Set up structured logging before anything else.
|
||||||
appLogger := mygolog.NewLogger(cfg.Log)
|
appLogger := logging.NewLogger(cfg.Log)
|
||||||
slog.SetDefault(appLogger)
|
slog.SetDefault(appLogger)
|
||||||
slog.Info("mygo server starting")
|
slog.Info("mygo server starting")
|
||||||
if loadInfo.EphemeralJWTSecret {
|
if loadInfo.EphemeralJWTSecret {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package log
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package log
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
mygolog "github.com/dhao2001/mygo/internal/log"
|
"github.com/dhao2001/mygo/internal/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RequestID returns a Gin middleware that ensures every request has a
|
// RequestID returns a Gin middleware that ensures every request has a
|
||||||
@@ -19,7 +19,7 @@ func RequestID() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inject into Go context for slog.*Context calls.
|
// Inject into Go context for slog.*Context calls.
|
||||||
c.Request = c.Request.WithContext(mygolog.WithRequestID(c.Request.Context(), reqID))
|
c.Request = c.Request.WithContext(logging.WithRequestID(c.Request.Context(), reqID))
|
||||||
|
|
||||||
// Also set in Gin context for direct access.
|
// Also set in Gin context for direct access.
|
||||||
c.Set("req_id", reqID)
|
c.Set("req_id", reqID)
|
||||||
|
|||||||
Reference in New Issue
Block a user