Refactor logging in ProtobufModule to ensure message details are logged after successful decoding (#9536)
This commit is contained in:
@@ -82,7 +82,6 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
|||||||
// it would be better to update even if the message was destined to others.
|
// it would be better to update even if the message was destined to others.
|
||||||
|
|
||||||
auto &p = mp.decoded;
|
auto &p = mp.decoded;
|
||||||
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d", name, mp.from, mp.id, p.portnum, p.payload.size);
|
|
||||||
|
|
||||||
T scratch;
|
T scratch;
|
||||||
T *decoded = NULL;
|
T *decoded = NULL;
|
||||||
@@ -90,6 +89,8 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
|||||||
memset(&scratch, 0, sizeof(scratch));
|
memset(&scratch, 0, sizeof(scratch));
|
||||||
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
|
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
|
||||||
decoded = &scratch;
|
decoded = &scratch;
|
||||||
|
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d", name, mp.from, mp.id, p.portnum,
|
||||||
|
p.payload.size);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("Error decoding proto module!");
|
LOG_ERROR("Error decoding proto module!");
|
||||||
// if we can't decode it, nobody can process it!
|
// if we can't decode it, nobody can process it!
|
||||||
|
|||||||
Reference in New Issue
Block a user