From 7f6a04e89e71099b6a61d9e99593f18e4124cb61 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 17 Dec 2024 01:22:20 +0100 Subject: [PATCH] Ignore UseToken. --- src/service.cr | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/service.cr b/src/service.cr index 3a69a46..5eba42c 100644 --- a/src/service.cr +++ b/src/service.cr @@ -10,12 +10,12 @@ class Array(T) end end -# WIP: select (dynamically) messages to mask - module DNSManager + # Select messages to mask in the logs (when everything goes well, of course). + # No need to flood the logs with keepalive messages or periodic token use, for instance. enum MESSAGE KEEPALIVE - # TODO + USETOKEN end end @@ -155,6 +155,7 @@ class DNSManager::Service < IPC Response::Error.new "generic error" end + respname = response.class.name.sub /^DNSManager::Response::/, "" # If clients sent requests with an “id” field, it is copied # in the responses. Allows identifying responses easily. response.id = request.id @@ -166,9 +167,11 @@ class DNSManager::Service < IPC if response.is_a? DNSManager::Response::Error Baguette::Log.warning "(#{connection_info_str}) (#{duration}) #{request} >> #{response}" else - if reqname != "KeepAlive" || should_display? DNSMESSAGE::KEEPALIVE - Baguette::Log.debug "(#{connection_info_str}) (#{duration}) #{request} >> #{response}" - end + # Different cases where we want to simply avoid logging redundant messages. + return if reqname == "KeepAlive" && ! should_display? DNSMESSAGE::KEEPALIVE + return if reqname == "UseToken" && respname == "Success" && ! should_display? DNSMESSAGE::USETOKEN + + Baguette::Log.debug "(#{connection_info_str}) (#{duration}) #{request} >> #{response}" end end