Skip to content

Commit

Permalink
Disable mDNS logging by default (#20008)
Browse files Browse the repository at this point in the history
By default, mDNS logging is enabled on Linux/Darwin platforms. This
creates a lot of logging noise to the point that it hinders debugging of
other issues.

This disables that by default and can be enabled selectively in
situations that need those logs.
  • Loading branch information
mrjerryjohns authored and pull[bot] committed Aug 21, 2023
1 parent 66a2dc7 commit da38588
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/lib/address_resolve/AddressResolve_DefaultImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@ void Resolver::ReArmTimer()

if (nextTimeout == kInvalidTimeout)
{
#if CHIP_MINMDNS_HIGH_VERBOSITY
// Generally this is only expected when no active lookups exist
ChipLogProgress(Discovery, "Discovery does not require any more timeouts");
#endif
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/dnssd/ActiveResolveAttempts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ void ActiveResolveAttempts::Complete(const PeerId & peerId)
}
}

#if CHIP_MINMDNS_HIGH_VERBOSITY
// This may happen during boot time adverisements: nodes come online
// and advertise their IP without any explicit queries for them
ChipLogProgress(Discovery, "Discovered node without a pending query");
#endif
}

void ActiveResolveAttempts::Complete(const chip::Dnssd::DiscoveredNodeData & data)
Expand Down
16 changes: 15 additions & 1 deletion src/lib/dnssd/Resolver_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,19 @@ void PacketParser::ParseResource(const ResourceData & data)
if (resolver.IsActive())
{
CHIP_ERROR err = resolver.OnRecord(mInterfaceId, data, mPacketRange);

//
// CHIP_ERROR_NO_MEMORY usually gets returned when we have no more memory available to hold the
// resolved data. This gets emitted fairly frequently in dense environments or when receiving records
// from devices with lots of interfaces. Consequently, don't log that unless we have DNS verbosity
// logging enabled.
//
if (err != CHIP_NO_ERROR)
{
ChipLogError(Discovery, "DNSSD parse error: %" CHIP_ERROR_FORMAT, err.Format());
#if !CHIP_MINMDNS_HIGH_VERBOSITY
if (err != CHIP_ERROR_NO_MEMORY)
#endif
ChipLogError(Discovery, "DNSSD parse error: %" CHIP_ERROR_FORMAT, err.Format());
}
}
}
Expand Down Expand Up @@ -365,7 +375,9 @@ void MinMdnsResolver::AdvancePendingResolverStates()
}
else
{
#if CHIP_MINMDNS_HIGH_VERBOSITY
ChipLogError(Discovery, "No delegate to report commissioning node discovery");
#endif
}
}
else if (resolver->IsActiveOperationalParse())
Expand All @@ -385,7 +397,9 @@ void MinMdnsResolver::AdvancePendingResolverStates()
}
else
{
#if CHIP_MINMDNS_HIGH_VERBOSITY
ChipLogError(Discovery, "No delegate to report operational node discovery");
#endif
}
}
else
Expand Down
7 changes: 3 additions & 4 deletions src/lib/dnssd/minimal_mdns/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ declare_args() {
current_os == "mac" || current_os == "linux" || current_os == "android" ||
current_os == "webos"

# Be very verbose regarding packet communication. Will spend extra RAM and
# Time to report mdns traffic in terms of sent and seen data.
chip_minmdns_high_verbosity =
current_os == "mac" || current_os == "linux" || current_os == "android"
# This enables verbose logging of sent/received mDNS messages. However, will incur extra RAM and
# time.
chip_minmdns_high_verbosity = false
}

config("config") {
Expand Down

0 comments on commit da38588

Please sign in to comment.