From 6bb80bdad5e07840d395c89489b04789814744f5 Mon Sep 17 00:00:00 2001 From: Linn3a Date: Sun, 15 Oct 2023 20:11:37 +0800 Subject: [PATCH] fix: delete log --- internal/handler/division.go | 7 +------ internal/server/middlewares.go | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/handler/division.go b/internal/handler/division.go index 6f944ac..3296c83 100644 --- a/internal/handler/division.go +++ b/internal/handler/division.go @@ -1,7 +1,6 @@ package handler import ( - "fmt" "github.com/gofiber/fiber/v2" "github.com/opentreehole/backend/internal/repository" "github.com/opentreehole/backend/internal/schema" @@ -95,13 +94,11 @@ func (h *divisionHandler) CreateDivision(c *fiber.Ctx) (err error) { c.Context().SetUserValue("FiberCtx", c) user, err := h.account.GetCurrentUser(c.Context()) - h.logger.Info(fmt.Sprintf("user: %+v", user)) + if err != nil { - h.logger.Info(fmt.Sprintf("err: %v", err)) return err } if !user.IsAdmin { - h.logger.Info(fmt.Sprintf("user: %+v", user)) return c.JSON(schema.Forbidden()) } @@ -146,8 +143,6 @@ func (h *divisionHandler) ModifyDivision(c *fiber.Ctx) (err error) { return c.JSON(schema.Forbidden()) } - h.logger.Info(fmt.Sprintf("user_id: %d", user.ID)) - response, err := h.service.ModifyDivision(c.Context(), id, &body) if err != nil { return err diff --git a/internal/server/middlewares.go b/internal/server/middlewares.go index d6d5d3c..6a058cf 100644 --- a/internal/server/middlewares.go +++ b/internal/server/middlewares.go @@ -7,11 +7,11 @@ import ( "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/rs/zerolog/log" - + fiberrecover "github.com/gofiber/fiber/v2/middleware/recover" "github.com/opentreehole/backend/internal/config" "github.com/opentreehole/backend/internal/schema" "github.com/opentreehole/backend/pkg/utils" + "github.com/rs/zerolog/log" ) func GetUserID(c *fiber.Ctx) (int, error) { @@ -94,7 +94,7 @@ func StackTraceHandler(_ *fiber.Ctx, e any) { func RegisterMiddlewares(conf *config.AtomicAllConfig) func(app *fiber.App) { return func(app *fiber.App) { - //app.Use(fiberrecover.New(fiberrecover.Config{EnableStackTrace: true, StackTraceHandler: StackTraceHandler})) + app.Use(fiberrecover.New(fiberrecover.Config{EnableStackTrace: true, StackTraceHandler: StackTraceHandler})) app.Use(MiddlewareGetUserID) if conf.Load().Mode != "bench" { app.Use(MiddlewareCustomLogger)