Merge branch 'fixLogMW' into 'staging'

Fix log mw

See merge request pena-services/customer!55
This commit is contained in:
Mikhail 2024-06-07 19:48:12 +00:00
commit e6a4341a7b
12 changed files with 34 additions and 104 deletions

4
go.mod

@ -20,9 +20,9 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240221002015-b0ce06bbee7c google.golang.org/genproto/googleapis/api v0.0.0-20240221002015-b0ce06bbee7c
google.golang.org/grpc v1.62.0 google.golang.org/grpc v1.62.0
google.golang.org/protobuf v1.33.0 google.golang.org/protobuf v1.33.0
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881 penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240607135420-4279d2c37763
) )
require ( require (

4
go.sum

@ -321,7 +321,11 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d h1:gbaDt35HMDqOK84WYmDIlXMI7rstUcRqNttaT6Kx1do= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d h1:gbaDt35HMDqOK84WYmDIlXMI7rstUcRqNttaT6Kx1do=
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a h1:dGW8ErUVdwGJBq6uc5AHYn6Yt10CDNkMIpV+yrDDTLs=
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881 h1:U1/WGQdwZsmrV/ta7Uqm13Dg07IPN/5omS8gzBJYZv4= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881 h1:U1/WGQdwZsmrV/ta7Uqm13Dg07IPN/5omS8gzBJYZv4=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240520145524-451212248881/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 h1:WlRVJnzU0sti+qBq/JTCgFPU0RoxIqGHu7hzDirxE2k= penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 h1:WlRVJnzU0sti+qBq/JTCgFPU0RoxIqGHu7hzDirxE2k=
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4= penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4=
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240607135420-4279d2c37763 h1:fzNg+Cqt2sb5DabtjleFs8mILL+KP8/eBfl7EIP5kBQ=
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240607135420-4279d2c37763/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4=

@ -66,7 +66,7 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
loggerForHlog := logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core { loggerForHlog := logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return zapcore.NewTee(core, clickHouseLogger) return zapcore.NewTee(core, clickHouseLogger)
})) }), zap.AddCallerSkip(2))
loggerHlog := hlog.New(loggerForHlog).Module(config.Service.ModuleLogger) loggerHlog := hlog.New(loggerForHlog).Module(config.Service.ModuleLogger)
loggerHlog.With(models.AllFields{}) loggerHlog.With(models.AllFields{})

@ -8,6 +8,7 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"go.uber.org/zap" "go.uber.org/zap"
"math" "math"
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils" qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client"
@ -15,7 +16,6 @@ import (
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
"strconv" "strconv"
"strings"
) )
type Deps struct { type Deps struct {
@ -103,7 +103,7 @@ func (receiver *AccountController) Get(ctx *fiber.Ctx) error {
return receiver.middleWare.NoAuth(ctx) return receiver.middleWare.NoAuth(ctx)
} }
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID) account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID)
if err != nil { if err != nil {
@ -111,10 +111,6 @@ func (receiver *AccountController) Get(ctx *fiber.Ctx) error {
} }
hlogger.Emit(models.InfoGetAccount{ hlogger.Emit(models.InfoGetAccount{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
CtxAccountID: account.ID, CtxAccountID: account.ID,
}) })
@ -128,7 +124,7 @@ func (receiver *AccountController) Create(ctx *fiber.Ctx) error {
return receiver.middleWare.NoAuth(ctx) return receiver.middleWare.NoAuth(ctx)
} }
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
var er error var er error
@ -167,10 +163,6 @@ func (receiver *AccountController) Create(ctx *fiber.Ctx) error {
} }
hlogger.Emit(models.InfoCreateAccount{ hlogger.Emit(models.InfoCreateAccount{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
CtxAccountID: account.ID, CtxAccountID: account.ID,
KeyFromSource: quiz, KeyFromSource: quiz,

@ -4,6 +4,7 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/timestamppb"
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/broker/tariff" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/broker/tariff"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client"
@ -84,7 +85,7 @@ func (receiver *CartController) Add2cart(ctx *fiber.Ctx) error {
return receiver.middleWare.NoAuth(ctx) return receiver.middleWare.NoAuth(ctx)
} }
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
tariffID := ctx.Query("id") tariffID := ctx.Query("id")
if tariffID == "" { if tariffID == "" {
@ -106,10 +107,6 @@ func (receiver *CartController) Add2cart(ctx *fiber.Ctx) error {
} }
hlogger.Emit(models.InfoAddToCart{ hlogger.Emit(models.InfoAddToCart{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
CtxAccountID: cartItems.ID, CtxAccountID: cartItems.ID,
CtxTariffID: tariffID, CtxTariffID: tariffID,
@ -129,7 +126,7 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error {
return receiver.middleWare.NoAuth(ctx) return receiver.middleWare.NoAuth(ctx)
} }
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID) account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID)
if err != nil { if err != nil {
@ -174,10 +171,6 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error {
if account.Wallet.Money < int64(discountResponse.Price) { if account.Wallet.Money < int64(discountResponse.Price) {
hlogger.Emit(models.InfoPayCart{ hlogger.Emit(models.InfoPayCart{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
CtxAccountID: account.ID, CtxAccountID: account.ID,
KeySuccess: false, KeySuccess: false,
@ -299,10 +292,6 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error {
updatedAccount.Cart = []string{} updatedAccount.Cart = []string{}
hlogger.Emit(models.InfoPayCart{ hlogger.Emit(models.InfoPayCart{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
CtxAccountID: updatedAccount.ID, CtxAccountID: updatedAccount.ID,
KeySuccess: true, KeySuccess: true,

@ -6,6 +6,7 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
"math" "math"
"os" "os"
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository"
@ -166,7 +167,7 @@ func (receiver *HistoryController) GetRecentTariffs(ctx *fiber.Ctx) error {
} }
func (receiver *HistoryController) SendReport(ctx *fiber.Ctx) error { func (receiver *HistoryController) SendReport(ctx *fiber.Ctx) error {
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
var req struct { var req struct {
Id string `json:"id"` Id string `json:"id"`
@ -284,10 +285,6 @@ func (receiver *HistoryController) SendReport(ctx *fiber.Ctx) error {
} }
hlogger.Emit(models.InfoReportRequest{ hlogger.Emit(models.InfoReportRequest{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: tariffs.UserID, CtxUserID: tariffs.UserID,
CtxAccountID: account.ID, CtxAccountID: account.ID,
CtxID: req.Id, CtxID: req.Id,

@ -3,7 +3,6 @@ package http
import ( import (
"fmt" "fmt"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/themakers/hlog"
"go.uber.org/zap" "go.uber.org/zap"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
) )
@ -54,8 +53,3 @@ func (mw *MiddleWare) ExtractToken(ctx *fiber.Ctx) (string, bool) {
func (mw *MiddleWare) GetHealth(ctx *fiber.Ctx) error { func (mw *MiddleWare) GetHealth(ctx *fiber.Ctx) error {
return ctx.Status(fiber.StatusOK).SendString("OK") return ctx.Status(fiber.StatusOK).SendString("OK")
} }
func (mw *MiddleWare) ExtractLogger(ctx *fiber.Ctx) hlog.Logger {
logger := ctx.Context().UserValue(models.LoggerKey).(hlog.Logger)
return logger
}

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"go.uber.org/zap" "go.uber.org/zap"
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/client"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/controller/http"
@ -13,7 +14,6 @@ import (
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/treasurer" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/treasurer"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate" "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
"strings"
) )
type Deps struct { type Deps struct {
@ -60,7 +60,7 @@ func (receiver *WalletController) RequestMoney(ctx *fiber.Ctx) error {
return receiver.middleWare.NoAuth(ctx) return receiver.middleWare.NoAuth(ctx)
} }
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
var request models.GetPaymentLinkBody var request models.GetPaymentLinkBody
if err := ctx.BodyParser(&request); err != nil { if err := ctx.BodyParser(&request); err != nil {
@ -71,6 +71,11 @@ func (receiver *WalletController) RequestMoney(ctx *fiber.Ctx) error {
return receiver.middleWare.ErrorOld(ctx, err) return receiver.middleWare.ErrorOld(ctx, err)
} }
account, err := receiver.accountRepo.FindByUserID(ctx.Context(), userID)
if err != nil {
return receiver.middleWare.ErrorOld(ctx, err)
}
link, err := receiver.GetPaymentLink(ctx.Context(), &models.GetPaymentLinkRequest{ link, err := receiver.GetPaymentLink(ctx.Context(), &models.GetPaymentLinkRequest{
Body: &request, Body: &request,
UserID: userID, UserID: userID,
@ -81,16 +86,11 @@ func (receiver *WalletController) RequestMoney(ctx *fiber.Ctx) error {
} }
hlogger.Emit(models.InfoRequestMoney{ hlogger.Emit(models.InfoRequestMoney{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
// todo CtxAccountID: account.ID,
CtxAccountID: "",
KeyPaymentType: string(request.Type), KeyPaymentType: string(request.Type),
KeyCurrency: request.Currency, KeyCurrency: request.Currency,
CtxPrice: int64(request.Amount), CtxPrice: request.Amount,
CtxReturnURL: link, CtxReturnURL: link,
}) })
@ -287,7 +287,7 @@ func (receiver *WalletController) PostWalletRspay(ctx *fiber.Ctx) error {
return receiver.middleWare.NoAuth(ctx) return receiver.middleWare.NoAuth(ctx)
} }
hlogger := receiver.middleWare.ExtractLogger(ctx) hlogger := log_mw.ExtractLogger(ctx)
var req struct { var req struct {
Money *float32 `json:"money,omitempty"` Money *float32 `json:"money,omitempty"`
@ -330,10 +330,6 @@ func (receiver *WalletController) PostWalletRspay(ctx *fiber.Ctx) error {
} }
hlogger.Emit(models.InfoRSPay{ hlogger.Emit(models.InfoRSPay{
CtxUserIP: ctx.IP(),
CtxUserPort: ctx.Port(),
KeyDomain: strings.Join(ctx.Subdomains(), "/"),
KeyPath: ctx.Path(),
CtxUserID: userID, CtxUserID: userID,
CtxAccountID: user.ID, CtxAccountID: user.ID,
CtxPrice: int64(*req.Money), CtxPrice: int64(*req.Money),

@ -15,4 +15,3 @@ type User struct {
const AuthJWTDecodedUserIDKey = "userID" const AuthJWTDecodedUserIDKey = "userID"
const AuthJWTDecodedAccessTokenKey = "access-token" const AuthJWTDecodedAccessTokenKey = "access-token"
const LoggerKey = "logger"

@ -28,10 +28,6 @@ type AllFields struct {
} }
type InfoCreateAccount struct { type InfoCreateAccount struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
KeyFromSource string //метка, откуда пришел пользователь. если куки quizFrom не пустые, ставить quiz KeyFromSource string //метка, откуда пришел пользователь. если куки quizFrom не пустые, ставить quiz
KeyFromID string //значение той куки, quizFrom KeyFromID string //значение той куки, quizFrom
@ -43,29 +39,17 @@ type InfoCreateAccount struct {
} }
type InfoGetAccount struct { type InfoGetAccount struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
CtxAccountID string // айдишник аккаунта CtxAccountID string // айдишник аккаунта
} }
type InfoAddToCart struct { type InfoAddToCart struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
CtxAccountID string // айдишник аккаунта CtxAccountID string // айдишник аккаунта
CtxTariffID string //айдишник тарифа, добавленного в корзину CtxTariffID string //айдишник тарифа, добавленного в корзину
} }
type InfoPayCart struct { type InfoPayCart struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
CtxAccountID string // айдишник аккаунта CtxAccountID string // айдишник аккаунта
KeySuccess bool // получилось оплатить или не хватило денег KeySuccess bool // получилось оплатить или не хватило денег
@ -77,10 +61,6 @@ type InfoPayCart struct {
} }
type InfoRequestMoney struct { type InfoRequestMoney struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
CtxAccountID string // айдишник аккаунта CtxAccountID string // айдишник аккаунта
KeyPaymentType string //направление оплаты, через которое оплачиваем KeyPaymentType string //направление оплаты, через которое оплачиваем
@ -98,10 +78,6 @@ type InfoMoneyIncome struct {
} }
type InfoReportRequest struct { type InfoReportRequest struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
CtxAccountID string // айдишник аккаунта CtxAccountID string // айдишник аккаунта
CtxID string //айдишник истории, по которой создаётся акт CtxID string //айдишник истории, по которой создаётся акт
@ -110,10 +86,6 @@ type InfoReportRequest struct {
} }
type InfoRSPay struct { type InfoRSPay struct {
CtxUserIP string
CtxUserPort string
KeyDomain string
KeyPath string
CtxUserID string //айдишник юзера из токена CtxUserID string //айдишник юзера из токена
CtxAccountID string // айдишник аккаунта CtxAccountID string // айдишник аккаунта
CtxPrice int64 // сумма в копейках CtxPrice int64 // сумма в копейках

@ -6,6 +6,7 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/themakers/hlog" "github.com/themakers/hlog"
"go.uber.org/zap" "go.uber.org/zap"
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
) )
@ -29,7 +30,7 @@ func NewServer(config ServerConfig) *Server {
jwtUtil := utils.NewJWT(config.JWTConfig) jwtUtil := utils.NewJWT(config.JWTConfig)
app.Use(utils.NewAuthenticator(jwtUtil)) app.Use(utils.NewAuthenticator(jwtUtil))
app.Use(utils.ContextLogger(config.Hlog)) app.Use(log_mw.ContextLogger(config.Hlog))
s := &Server{ s := &Server{
Logger: config.Logger, Logger: config.Logger,

@ -1,14 +0,0 @@
package utils
import (
"github.com/gofiber/fiber/v2"
"github.com/themakers/hlog"
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
)
func ContextLogger(logger hlog.Logger) fiber.Handler {
return func(c *fiber.Ctx) error {
c.Locals(models.LoggerKey, logger)
return c.Next()
}
}