feat: implement logger
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/customerService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/logger"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/query_params"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
@@ -64,6 +65,13 @@ func (h *customerHandler) customerData(fc fiber.Ctx) error {
|
||||
|
||||
customer, err := h.service.GetById(customerId)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to get customer",
|
||||
"handler", "customerHandler.customerData",
|
||||
|
||||
"customer_id", customerId,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return fc.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, err)))
|
||||
}
|
||||
@@ -88,6 +96,12 @@ func (h *customerHandler) listCustomers(fc fiber.Ctx) error {
|
||||
|
||||
customer, err := h.service.Find(user.LangID, p, filt, search)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to list customers",
|
||||
"handler", "customerHandler.listCustomers",
|
||||
|
||||
"error", err.Error(),
|
||||
)
|
||||
return fc.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, err)))
|
||||
}
|
||||
@@ -120,6 +134,13 @@ func (h *customerHandler) setCustomerNoVatStatus(fc fiber.Ctx) error {
|
||||
}
|
||||
|
||||
if err := h.service.SetCustomerNoVatStatus(req.CustomerID, req.IsNoVat); err != nil {
|
||||
|
||||
logger.Error("failed to set customer no vat status",
|
||||
"handler", "customerHandler.setCustomerNoVatStatus",
|
||||
|
||||
"customer_id", req.CustomerID,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return fc.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, err)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user