Skip to content

Commit

Permalink
Add debug logs for raw json messages
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo <lorenzo.donini90@gmail.com>
  • Loading branch information
lorenzodonini committed Feb 24, 2023
1 parent 8c6098d commit 0195c3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ocppj/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func (c *Client) SendResponse(requestId string, response ocpp.Response) error {
return err
}
log.Debugf("sent CALL RESULT [%s]", callResult.UniqueId)
log.Debugf("sent JSON message to server: %s", string(jsonMessage))
return nil
}

Expand Down Expand Up @@ -211,6 +212,7 @@ func (c *Client) ocppMessageHandler(data []byte) error {
log.Error(err)
return err
}
log.Debugf("received JSON message from server: %s", string(data))
message, err := c.ParseMessage(parsedJson, c.RequestState)
if err != nil {
ocppErr := err.(*ocpp.Error)
Expand Down
3 changes: 3 additions & 0 deletions ocppj/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ func (d *DefaultClientDispatcher) dispatchNextRequest() {
ocpp.NewError(InternalError, err.Error(), bundle.Call.UniqueId))
}
}
log.Infof("dispatched request %s to server", bundle.Call.UniqueId)
log.Debugf("sent JSON message to server: %s", string(jsonMessage))
}

func (d *DefaultClientDispatcher) Pause() {
Expand Down Expand Up @@ -569,6 +571,7 @@ func (d *DefaultServerDispatcher) dispatchNextRequest(clientID string) (clientCt
clientCtx = clientTimeoutContext{ctx: ctx, cancel: cancel}
}
log.Infof("dispatched request %s for %s", callID, clientID)
log.Debugf("sent JSON message to %s: %s", clientID, string(jsonMessage))
return
}

Expand Down
2 changes: 2 additions & 0 deletions ocppj/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func (s *Server) SendResponse(clientID string, requestId string, response ocpp.R
return err
}
log.Debugf("sent CALL RESULT [%s] for %s", callResult.UniqueId, clientID)
log.Debugf("sent JSON message to %s: %s", clientID, string(jsonMessage))
return nil
}

Expand Down Expand Up @@ -205,6 +206,7 @@ func (s *Server) ocppMessageHandler(wsChannel ws.Channel, data []byte) error {
log.Error(err)
return err
}
log.Debugf("received JSON message from %s: %s", wsChannel.ID(), string(data))
// Get pending requests for client
pending := s.RequestState.GetClientState(wsChannel.ID())
message, err := s.ParseMessage(parsedJson, pending)
Expand Down

0 comments on commit 0195c3f

Please sign in to comment.