Skip to content

Commit 963b267

Browse files
Improve DNS-SD resolution logging.
When logging that we are checking for results, include the instance name we are checking for. Otherwise the logs are completely inscrutable when multiple resolves are in progress at the same time.
1 parent 9b9ed65 commit 963b267

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/lib/address_resolve/AddressResolve_DefaultImpl.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ NodeLookupAction NodeLookupHandle::NextAction(System::Clock::Timestamp now)
9797
{
9898
const System::Clock::Timestamp elapsed = now - mRequestStartTime;
9999

100-
ChipLogProgress(Discovery, "Checking node lookup status after %lu ms", static_cast<unsigned long>(elapsed.count()));
100+
ChipLogProgress(Discovery, "Checking node lookup status for " ChipLogFormatPeerId " after %lu ms",
101+
ChipLogValuePeerId(mRequest.GetPeerId()), static_cast<unsigned long>(elapsed.count()));
101102

102103
// We are still within the minimal search time. Wait for more results.
103104
if (elapsed < mRequest.GetMinLookupTime())
@@ -186,9 +187,11 @@ CHIP_ERROR Resolver::LookupNode(const NodeLookupRequest & request, Impl::NodeLoo
186187
VerifyOrReturnError(mSystemLayer != nullptr, CHIP_ERROR_INCORRECT_STATE);
187188

188189
handle.ResetForLookup(mTimeSource.GetMonotonicTimestamp(), request);
189-
ReturnErrorOnFailure(Dnssd::Resolver::Instance().ResolveNodeId(request.GetPeerId()));
190+
auto & peerId = request.GetPeerId();
191+
ReturnErrorOnFailure(Dnssd::Resolver::Instance().ResolveNodeId(peerId));
190192
mActiveLookups.PushBack(&handle);
191193
ReArmTimer();
194+
ChipLogProgress(Discovery, "Lookup started for " ChipLogFormatPeerId, ChipLogValuePeerId(peerId));
192195
return CHIP_NO_ERROR;
193196
}
194197

src/lib/dnssd/Types.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,7 @@ struct ResolvedNodeData
289289
#if CHIP_PROGRESS_LOGGING
290290
// Would be nice to log the interface id, but sorting out how to do so
291291
// across our different InterfaceId implementations is a pain.
292-
ChipLogProgress(Discovery, "Node ID resolved for " ChipLogFormatX64 ":" ChipLogFormatX64,
293-
ChipLogValueX64(operationalData.peerId.GetCompressedFabricId()),
294-
ChipLogValueX64(operationalData.peerId.GetNodeId()));
292+
ChipLogProgress(Discovery, "Node ID resolved for " ChipLogFormatPeerId, ChipLogValuePeerId(operationalData.peerId));
295293
resolutionData.LogDetail();
296294
#endif // CHIP_PROGRESS_LOGGING
297295
}

src/lib/support/logging/TextOnlyLogging.h

+8
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ using LogRedirectCallback_t = void (*)(const char * module, uint8_t category, co
313313
#define ChipLogFormatScopedNodeId "<" ChipLogFormatX64 ", %d>"
314314
#define ChipLogValueScopedNodeId(id) ChipLogValueX64((id).GetNodeId()), (id).GetFabricIndex()
315315

316+
/** Logging helpers for PeerId, which is a tuple of <Compressed Fabric Id, NodeId>
317+
*
318+
* This gets logged in the form that's used for the DNS-SD instance name for the
319+
* peer.
320+
*/
321+
#define ChipLogFormatPeerId ChipLogFormatX64 "-" ChipLogFormatX64
322+
#define ChipLogValuePeerId(id) ChipLogValueX64((id).GetCompressedFabricId()), ChipLogValueX64((id).GetNodeId())
323+
316324
/**
317325
* CHIP Logging Implementation internals.
318326
*/

0 commit comments

Comments
 (0)