mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(logging): replace all the loggers with zerolog EE-4186 (#7663)
This commit is contained in:
parent
53025178ef
commit
36e7981ab7
109 changed files with 1101 additions and 662 deletions
|
@ -9,7 +9,8 @@ import (
|
|||
"github.com/portainer/libhttp/response"
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
bolterrors "github.com/portainer/portainer/api/dataservices/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// @id OpenAMTDevices
|
||||
|
@ -67,6 +68,7 @@ func (payload *deviceActionPayload) Validate(r *http.Request) error {
|
|||
if payload.Action == "" {
|
||||
return errors.New("device action must be provided")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -93,7 +95,8 @@ func (handler *Handler) deviceAction(w http.ResponseWriter, r *http.Request) *ht
|
|||
var payload deviceActionPayload
|
||||
err = request.DecodeAndValidateJSONPayload(r, &payload)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Invalid request payload")
|
||||
log.Error().Err(err).Msg("invalid request payload")
|
||||
|
||||
return httperror.BadRequest("Invalid request payload", err)
|
||||
}
|
||||
|
||||
|
@ -104,7 +107,8 @@ func (handler *Handler) deviceAction(w http.ResponseWriter, r *http.Request) *ht
|
|||
|
||||
err = handler.OpenAMTService.ExecuteDeviceAction(settings.OpenAMTConfiguration, deviceID, payload.Action)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Error executing device action")
|
||||
log.Error().Err(err).Msg("error executing device action")
|
||||
|
||||
return httperror.BadRequest("Error executing device action", err)
|
||||
}
|
||||
|
||||
|
@ -119,6 +123,7 @@ func (payload *deviceFeaturesPayload) Validate(r *http.Request) error {
|
|||
if payload.Features.UserConsent == "" {
|
||||
return errors.New("device user consent status must be provided")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -150,7 +155,8 @@ func (handler *Handler) deviceFeatures(w http.ResponseWriter, r *http.Request) *
|
|||
var payload deviceFeaturesPayload
|
||||
err = request.DecodeAndValidateJSONPayload(r, &payload)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Invalid request payload")
|
||||
log.Error().Err(err).Msg("invalid request payload")
|
||||
|
||||
return httperror.BadRequest("Invalid request payload", err)
|
||||
}
|
||||
|
||||
|
@ -166,7 +172,8 @@ func (handler *Handler) deviceFeatures(w http.ResponseWriter, r *http.Request) *
|
|||
|
||||
token, err := handler.OpenAMTService.EnableDeviceFeatures(settings.OpenAMTConfiguration, deviceID, payload.Features)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Error executing device action")
|
||||
log.Error().Err(err).Msg("error executing device action")
|
||||
|
||||
return httperror.BadRequest("Error executing device action", err)
|
||||
}
|
||||
|
||||
|
@ -174,5 +181,6 @@ func (handler *Handler) deviceFeatures(w http.ResponseWriter, r *http.Request) *
|
|||
Server: settings.OpenAMTConfiguration.MPSServer,
|
||||
Token: token,
|
||||
}
|
||||
|
||||
return response.JSON(w, authorizationResponse)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue