diff --git a/app/app.go b/app/app.go index de1d382..e448c70 100644 --- a/app/app.go +++ b/app/app.go @@ -12,6 +12,7 @@ import ( "github.com/themakers/hlog" "go.uber.org/zap" "go.uber.org/zap/zapcore" + "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" dalBS "penahub.gitlab.yandexcloud.net/backend/quiz/answerer.git/dal" "penahub.gitlab.yandexcloud.net/backend/quiz/answerer.git/models" "penahub.gitlab.yandexcloud.net/backend/quiz/answerer.git/savewc" @@ -159,7 +160,7 @@ func New(ctx context.Context, opts interface{}, ver appInit.Version) (appInit.Co app := fiber.New(fiber.Config{BodyLimit: 70 * 1024 * 1024}) app.Use(middleware.AnswererChain()) - app.Use(middleware.ContextLogger(loggerHlog)) + app.Use(log_mw.ContextLogger(loggerHlog)) app.Get("/liveness", healthchecks.Liveness) app.Get("/readiness", healthchecks.Readiness(&workerErr)) //todo parametrized readiness. should discuss ready reason app = svc.Register(app) diff --git a/go.mod b/go.mod index fc9706e..bae7bb2 100644 --- a/go.mod +++ b/go.mod @@ -46,5 +46,5 @@ require ( google.golang.org/grpc v1.47.0 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c // indirect + penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a // indirect ) diff --git a/go.sum b/go.sum index aa878fc..b517b04 100644 --- a/go.sum +++ b/go.sum @@ -272,6 +272,8 @@ 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= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c h1:jxnyIeC2CNDNmfdFx2qnLS4Qd0v5ocYrY9X+OL9qsvc= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c/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-20240601180932-af93405efbcf h1:BnzAkKXo6CksQTqpVzsCTSMdWNwMpkBKb8eS/DDDHBI= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240601180932-af93405efbcf/go.mod h1:n66zm88Dh12+idyfqh0vU5nd9BZYxM6Pv0XYnmy0398= penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 h1:WlRVJnzU0sti+qBq/JTCgFPU0RoxIqGHu7hzDirxE2k= diff --git a/models/hlog_events.go b/models/hlog_events.go index 864f422..bc24fbc 100644 --- a/models/hlog_events.go +++ b/models/hlog_events.go @@ -18,10 +18,6 @@ type AllFields struct { } type InfoQuizOpen struct { // при получении настроек квиза - CtxUserIP string - CtxUserPort string - KeyDomain string - KeyPath string KeyOS, KeyDevice, KeyDeviceType, KeyBrowser string // то самое, что получается из заголовков и складывается в модель ответа. на самом деле, ему место тут CtxQuiz string // айдишник квиза, который qid CtxQuizID uint64 // айдишник квиза @@ -31,10 +27,6 @@ type InfoQuizOpen struct { // при получении настроек кви } type InfoAnswer struct { // при любом ответе на вопрос - CtxUserIP string - CtxUserPort string - KeyDomain string - KeyPath string KeyOS, KeyDevice, KeyDeviceType, KeyBrowser string // то самое, что получается из заголовков и складывается в модель ответа. на самом деле, ему место тут CtxQuiz string // айдишник квиза, который qid CtxQuizID uint64 // айдишник квиза @@ -45,10 +37,6 @@ type InfoAnswer struct { // при любом ответе на вопрос } type InfoResult struct { // если ответ на вопрос с типом result - CtxUserIP string - CtxUserPort string - KeyDomain string - KeyPath string KeyOS, KeyDevice, KeyDeviceType, KeyBrowser string // то самое, что получается из заголовков и складывается в модель ответа. на самом деле, ему место тут CtxQuiz string // айдишник квиза, который qid CtxQuizID uint64 // айдишник квиза @@ -60,10 +48,6 @@ type InfoResult struct { // если ответ на вопрос с типом // todo понять для чего это событие вроде как контакты приходят в ответахс с result = true там парситься контент с контактной информацией type InfoContactForm struct { // если ответ на вопрос с типом result, без result == true (возможно перепутал с предыдущим. в этом ответе приходят контактные данные респондента) - CtxUserIP string - CtxUserPort string - KeyDomain string - KeyPath string KeyOS, KeyDevice, KeyDeviceType, KeyBrowser string // то самое, что получается из заголовков и складывается в модель ответа. на самом деле, ему место тут CtxQuiz string // айдишник квиза, который qid CtxQuizID uint64 // айдишник квиза diff --git a/service/service.go b/service/service.go index 0040d5a..d621b83 100644 --- a/service/service.go +++ b/service/service.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "github.com/gofiber/fiber/v2" + "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" "penahub.gitlab.yandexcloud.net/backend/quiz/answerer.git/dal" "penahub.gitlab.yandexcloud.net/backend/quiz/answerer.git/models" quizdal "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" @@ -88,7 +89,7 @@ type ShavedQuestion struct { // GetQuizData handler for obtaining data for quiz front rendering func (s *Service) GetQuizData(c *fiber.Ctx) error { - hlogger := middleware.GetLogger(c) + hlogger := log_mw.ExtractLogger(c) var req GetQuizDataReq if err := c.BodyParser(&req); err != nil { return c.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -223,10 +224,6 @@ func (s *Service) GetQuizData(c *fiber.Ctx) error { } hlogger.Emit(models.InfoQuizOpen{ - CtxUserIP: c.IP(), - CtxUserPort: c.Port(), - KeyDomain: strings.Join(c.Subdomains(), "/"), - KeyPath: c.Path(), KeyOS: os, KeyDevice: device, KeyDeviceType: deviceType, @@ -291,7 +288,7 @@ func (s *Service) PutAnswersOnePiece(c *fiber.Ctx) error { return c.Status(fiber.StatusUnauthorized).SendString("no session in cookie") } - hlogger := middleware.GetLogger(c) + hlogger := log_mw.ExtractLogger(c) form, err := c.MultipartForm() if err != nil || form == nil || form.File == nil { @@ -411,10 +408,6 @@ func (s *Service) PutAnswersOnePiece(c *fiber.Ctx) error { questionIDs = append(questionIDs, ans.QuestionId) if ans.Result { hlogger.Emit(models.InfoResult{ - CtxUserIP: c.IP(), - CtxUserPort: c.Port(), - KeyDomain: strings.Join(c.Subdomains(), "/"), - KeyPath: c.Path(), KeyOS: os, KeyDevice: device, KeyDeviceType: deviceType, @@ -429,10 +422,6 @@ func (s *Service) PutAnswersOnePiece(c *fiber.Ctx) error { continue } hlogger.Emit(models.InfoAnswer{ - CtxUserIP: c.IP(), - CtxUserPort: c.Port(), - KeyDomain: strings.Join(c.Subdomains(), "/"), - KeyPath: c.Path(), KeyOS: os, KeyDevice: device, KeyDeviceType: deviceType,