Skip to content

Commit cbe17ed

Browse files
Reduce logging in BDXTransferSession by removing logging for BlockQue… (#37412)
* Reduce logging in BDXTransferSession by removing logging for BlockQuery, Block and BlockAck messages as they generate a lot of logs - The Exchange Manager alreadys logs the BlockQuery, Block and BlockAck messages and that can be used for debugging purposes - Do not log messages for OutputEvent when the event type is None - Also reduce additional logging in the darwin code. * Restyle * Address review comments * Fix whitespace restyled issue. --------- Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 93114c7 commit cbe17ed

File tree

3 files changed

+20
-44
lines changed

3 files changed

+20
-44
lines changed

src/darwin/Framework/CHIP/MTROTAImageTransferHandler.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ - (instancetype)initWithMTROTAImageTransferHandler:(MTROTAImageTransferHandler *
310310

311311
TransferSession::OutputEventType eventType = event.EventType;
312312

313-
ChipLogError(BDX, "OutputEvent type: %s", event.ToString(eventType));
313+
ChipLogDetail(BDX, "OutputEvent type: %s", event.ToString(eventType));
314314

315315
CHIP_ERROR err = CHIP_NO_ERROR;
316316
switch (event.EventType) {

src/protocols/bdx/AsyncTransferFacilitator.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ CHIP_ERROR AsyncResponder::Init(System::Layer * layer, Messaging::ExchangeContex
178178

179179
void AsyncResponder::NotifyEventHandled(const TransferSession::OutputEventType eventType, CHIP_ERROR status)
180180
{
181-
ChipLogDetail(BDX, "NotifyEventHandled : Event %s Error %" CHIP_ERROR_FORMAT,
182-
TransferSession::OutputEvent::TypeToString(eventType), status.Format());
183-
184181
// If this is the end of the transfer (whether a clean end, or some sort of error condition), ensure
185182
// that we destroy ourselves after unwinding the processing loop in the ProcessOutputEvents API.
186183
// We can ignore the status for these output events because none of them are supposed to result in
@@ -194,6 +191,8 @@ void AsyncResponder::NotifyEventHandled(const TransferSession::OutputEventType e
194191
eventType == TransferSession::OutputEventType::kTransferTimeout ||
195192
eventType == TransferSession::OutputEventType::kStatusReceived)
196193
{
194+
ChipLogProgress(BDX, "NotifyEventHandled : Event %s Error %" CHIP_ERROR_FORMAT,
195+
TransferSession::OutputEvent::TypeToString(eventType), status.Format());
197196
mDestroySelfAfterProcessingEvents = true;
198197
}
199198
else if (status != CHIP_NO_ERROR)

src/protocols/bdx/BdxTransferSession.cpp

+17-40
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,6 @@ CHIP_ERROR TransferSession::PrepareBlockQuery()
291291

292292
ReturnErrorOnFailure(WriteToPacketBuffer(queryMsg, mPendingMsgHandle));
293293

294-
#if CHIP_AUTOMATION_LOGGING
295-
ChipLogAutomation("Sending BDX Message");
296-
queryMsg.LogMessage(msgType);
297-
#endif // CHIP_AUTOMATION_LOGGING
298-
299294
mAwaitingResponse = true;
300295
mLastQueryNum = mNextQueryNum++;
301296

@@ -319,11 +314,6 @@ CHIP_ERROR TransferSession::PrepareBlockQueryWithSkip(const uint64_t & bytesToSk
319314

320315
ReturnErrorOnFailure(WriteToPacketBuffer(queryMsg, mPendingMsgHandle));
321316

322-
#if CHIP_AUTOMATION_LOGGING
323-
ChipLogAutomation("Sending BDX Message");
324-
queryMsg.LogMessage(msgType);
325-
#endif // CHIP_AUTOMATION_LOGGING
326-
327317
mAwaitingResponse = true;
328318
mLastQueryNum = mNextQueryNum++;
329319

@@ -351,13 +341,12 @@ CHIP_ERROR TransferSession::PrepareBlock(const BlockData & inData)
351341

352342
const MessageType msgType = inData.IsEof ? MessageType::BlockEOF : MessageType::Block;
353343

354-
#if CHIP_AUTOMATION_LOGGING
355-
ChipLogAutomation("Sending BDX Message");
356-
blockMsg.LogMessage(msgType);
357-
#endif // CHIP_AUTOMATION_LOGGING
358-
359344
if (msgType == MessageType::BlockEOF)
360345
{
346+
#if CHIP_AUTOMATION_LOGGING
347+
ChipLogAutomation("Sending BDX Message");
348+
blockMsg.LogMessage(msgType);
349+
#endif // CHIP_AUTOMATION_LOGGING
361350
mState = TransferState::kAwaitingEOFAck;
362351
}
363352

@@ -382,11 +371,6 @@ CHIP_ERROR TransferSession::PrepareBlockAck()
382371

383372
ReturnErrorOnFailure(WriteToPacketBuffer(ackMsg, mPendingMsgHandle));
384373

385-
#if CHIP_AUTOMATION_LOGGING
386-
ChipLogAutomation("Sending BDX Message");
387-
ackMsg.LogMessage(msgType);
388-
#endif // CHIP_AUTOMATION_LOGGING
389-
390374
if (mState == TransferState::kTransferInProgress)
391375
{
392376
if (mControlMode == TransferControlFlags::kSenderDrive)
@@ -399,6 +383,10 @@ CHIP_ERROR TransferSession::PrepareBlockAck()
399383
}
400384
else if (mState == TransferState::kReceivedEOF)
401385
{
386+
#if CHIP_AUTOMATION_LOGGING
387+
ChipLogAutomation("Sending BDX Message");
388+
ackMsg.LogMessage(msgType);
389+
#endif // CHIP_AUTOMATION_LOGGING
402390
mState = TransferState::kTransferDone;
403391
mAwaitingResponse = false;
404392
}
@@ -475,20 +463,25 @@ CHIP_ERROR TransferSession::HandleBdxMessage(const PayloadHeader & header, Syste
475463

476464
const MessageType msgType = static_cast<MessageType>(header.GetMessageType());
477465

478-
#if CHIP_AUTOMATION_LOGGING
479-
ChipLogAutomation("Handling received BDX Message");
480-
#endif // CHIP_AUTOMATION_LOGGING
481-
482466
switch (msgType)
483467
{
484468
case MessageType::SendInit:
485469
case MessageType::ReceiveInit:
470+
#if CHIP_AUTOMATION_LOGGING
471+
ChipLogAutomation("Handling received BDX Message");
472+
#endif // CHIP_AUTOMATION_LOGGING
486473
HandleTransferInit(msgType, std::move(msg));
487474
break;
488475
case MessageType::SendAccept:
476+
#if CHIP_AUTOMATION_LOGGING
477+
ChipLogAutomation("Handling received BDX Message");
478+
#endif // CHIP_AUTOMATION_LOGGING
489479
HandleSendAccept(std::move(msg));
490480
break;
491481
case MessageType::ReceiveAccept:
482+
#if CHIP_AUTOMATION_LOGGING
483+
ChipLogAutomation("Handling received BDX Message");
484+
#endif // CHIP_AUTOMATION_LOGGING
492485
HandleReceiveAccept(std::move(msg));
493486
break;
494487
case MessageType::BlockQuery:
@@ -672,10 +665,6 @@ void TransferSession::HandleBlockQuery(System::PacketBufferHandle msgData)
672665

673666
mAwaitingResponse = false;
674667
mLastQueryNum = query.BlockCounter;
675-
676-
#if CHIP_AUTOMATION_LOGGING
677-
query.LogMessage(MessageType::BlockQuery);
678-
#endif // CHIP_AUTOMATION_LOGGING
679668
}
680669

681670
void TransferSession::HandleBlockQueryWithSkip(System::PacketBufferHandle msgData)
@@ -695,10 +684,6 @@ void TransferSession::HandleBlockQueryWithSkip(System::PacketBufferHandle msgDat
695684
mAwaitingResponse = false;
696685
mLastQueryNum = query.BlockCounter;
697686
mBytesToSkip.BytesToSkip = query.BytesToSkip;
698-
699-
#if CHIP_AUTOMATION_LOGGING
700-
query.LogMessage(MessageType::BlockQueryWithSkip);
701-
#endif // CHIP_AUTOMATION_LOGGING
702687
}
703688

704689
void TransferSession::HandleBlock(System::PacketBufferHandle msgData)
@@ -733,10 +718,6 @@ void TransferSession::HandleBlock(System::PacketBufferHandle msgData)
733718
mLastBlockNum = blockMsg.BlockCounter;
734719

735720
mAwaitingResponse = false;
736-
737-
#if CHIP_AUTOMATION_LOGGING
738-
blockMsg.LogMessage(MessageType::Block);
739-
#endif // CHIP_AUTOMATION_LOGGING
740721
}
741722

742723
void TransferSession::HandleBlockEOF(System::PacketBufferHandle msgData)
@@ -787,10 +768,6 @@ void TransferSession::HandleBlockAck(System::PacketBufferHandle msgData)
787768
// In Receiver Drive, the Receiver can send a BlockAck to indicate receipt of the message and reset the timeout.
788769
// In this case, the Sender should wait to receive a BlockQuery next.
789770
mAwaitingResponse = (mControlMode == TransferControlFlags::kReceiverDrive);
790-
791-
#if CHIP_AUTOMATION_LOGGING
792-
ackMsg.LogMessage(MessageType::BlockAck);
793-
#endif // CHIP_AUTOMATION_LOGGING
794771
}
795772

796773
void TransferSession::HandleBlockAckEOF(System::PacketBufferHandle msgData)

0 commit comments

Comments
 (0)