From a53d99de24d9237576cec45cffd6b5c47309c6d6 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Thu, 25 Apr 2019 10:30:50 +1200 Subject: [PATCH] feat(ServiceDiscovery): when tracing pretty print the DNS message --- src/Mdns.csproj | 2 +- src/ServiceDiscovery.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Mdns.csproj b/src/Mdns.csproj index b42774f..d677193 100644 --- a/src/Mdns.csproj +++ b/src/Mdns.csproj @@ -33,7 +33,7 @@ - + diff --git a/src/ServiceDiscovery.cs b/src/ServiceDiscovery.cs index 307d3ff..7a8413b 100644 --- a/src/ServiceDiscovery.cs +++ b/src/ServiceDiscovery.cs @@ -228,7 +228,11 @@ void OnQuery(object sender, MessageEventArgs e) if (log.IsDebugEnabled) { - log.Debug($"got query from: {e.RemoteEndPoint}, for {request.Questions[0].Name} {request.Questions[0].Type}"); + log.Debug($"Query from {e.RemoteEndPoint}"); + } + if (log.IsTraceEnabled) + { + log.Trace(request); } // Determine if this query is requesting a unicast response @@ -274,7 +278,11 @@ void OnQuery(object sender, MessageEventArgs e) if (log.IsDebugEnabled) { - log.Debug($"sent answer {response.Answers[0]}"); + log.Debug($"Sending answer"); + } + if (log.IsTraceEnabled) + { + log.Trace(response); } //Console.WriteLine($"Response time {(DateTime.Now - request.CreationTime).TotalMilliseconds}ms"); }