(minor) change the way messages are printed.

This commit is contained in:
Philippe Pittoli 2024-03-17 23:07:02 +01:00
parent ffa4cd6b37
commit 729139232d

View File

@ -92,41 +92,38 @@ class DNSManager::Service < IPC
end
reqname = request.class.name.sub /^DNSManager::Request::/, ""
if reqname != "KeepAlive" || @configuration.print_keepalive
Baguette::Log.debug "<< #{reqname}"
end
response = begin
request.handle self, event
rescue e : AuthorizationException
Baguette::Log.error "#{reqname} authorization error"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} authorization error"
Response::Error.new "authorization error"
rescue e : DomainNotFoundException
Baguette::Log.error "#{reqname} domain not found"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} domain not found"
Response::DomainNotFound.new
rescue e : UnknownUserException
Baguette::Log.error "#{reqname} unknown user"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} unknown user"
Response::UnknownUser.new
rescue e : NoOwnershipException
Baguette::Log.error "#{reqname} no ownership error"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} no ownership error"
Response::NoOwnership.new
rescue e : AdminAuthorizationException
Baguette::Log.error "#{reqname} no admin authorization"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} no admin authorization"
Response::Error.new "admin authorization error"
rescue e : NotLoggedException
Baguette::Log.error "#{reqname} user not logged"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} user not logged"
Response::Error.new "user not logged"
rescue e : RRNotFoundException
Baguette::Log.error "#{reqname} RR not found"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} RR not found"
Response::RRNotFound.new
rescue e : TokenNotFoundException
Baguette::Log.error "#{reqname} Token not found"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} Token not found"
Response::Error.new "token not found"
rescue e : RRReadOnlyException
Baguette::Log.error "#{reqname} RR is read only"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} RR is read only"
Response::RRReadOnly.new e.domain, e.rr
rescue e # Generic case
Baguette::Log.error "#{reqname} generic error #{e}"
Baguette::Log.error "(fd #{"%4d" % event.fd}) #{reqname} generic error #{e}"
Response::Error.new "generic error"
end
@ -141,10 +138,10 @@ class DNSManager::Service < IPC
response_name = response.class.name.sub /^DNSManager::Response::/, ""
if response.is_a? DNSManager::Response::Error
Baguette::Log.warning ">> #{response_name} (#{response.reason}) (Total duration: #{duration})"
Baguette::Log.warning "fd #{"%4d" % event.fd} (#{duration}) #{reqname} >> #{response_name} (#{response.reason})"
else
if reqname != "KeepAlive" || @configuration.print_keepalive
Baguette::Log.debug ">> #{response_name} (Total duration: #{duration})"
Baguette::Log.debug "fd #{"%4d" % event.fd} (#{duration}) #{reqname} >> #{response_name}"
end
end
end