Skip to content

Commit

Permalink
wip: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Aug 21, 2022
1 parent 007ebca commit 7974e3c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/native/message_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,26 +387,40 @@ func (m *Message) WithPluginInteractionContents(part interactionPart, contentTyp
// if the contents is from a plugin, the byte[] representation of the parsed
// plugin data is returned, again, with any matchers etc. removed
func (m *Message) GetMessageRequestContents() ([]byte, error) {
log.Println("[DEBUG] GetMessageRequestContents")
if m.messageType == MESSAGE_TYPE_ASYNC {
iter := C.pactffi_pact_handle_get_message_iter(m.pact.handle)
log.Println("[DEBUG] pactffi_pact_handle_get_message_iter")
if iter == nil {
return nil, errors.New("unable to get a message iterator")
}
log.Println("[DEBUG] pactffi_pact_handle_get_message_iter - OK")

///////
// TODO: some debugging in here to see what's exploding.......
///////

log.Println("[DEBUG] pactffi_pact_handle_get_message_iter - len", len(m.server.messages))

for i := 0; i < len(m.server.messages); i++ {
log.Println("[DEBUG] pactffi_pact_handle_get_message_iter - index", i)
message := C.pactffi_pact_message_iter_next(iter)
log.Println("[DEBUG] pactffi_pact_message_iter_next - message", message)

if i == m.index {
log.Println("[DEBUG] pactffi_pact_message_iter_next - index match", message)

if message == nil {
return nil, errors.New("retreived a null message pointer")
}

len := C.pactffi_message_get_contents_length(message)
log.Println("[DEBUG] pactffi_message_get_contents_length - len", len)
if len == 0 {
return nil, errors.New("retreived an empty message")
}
data := C.pactffi_message_get_contents_bin(message)
log.Println("[DEBUG] pactffi_message_get_contents_bin - data", data)
if data == nil {
return nil, errors.New("retreived an empty pointer to the message contents")
}
Expand Down

0 comments on commit 7974e3c

Please sign in to comment.