(minor) change the way logs are printed.

This commit is contained in:
Philippe Pittoli 2024-03-17 23:16:18 +01:00
parent 9ff86ae846
commit 2df24a583e

View File

@ -111,23 +111,20 @@ class AuthD::Service < IPC
end end
request_name = request.class.name.sub /^AuthD::Request::/, "" request_name = request.class.name.sub /^AuthD::Request::/, ""
if request_name != "KeepAlive" || @configuration.print_keepalive
Baguette::Log.debug "<< #{request_name} (FROM: #{event.fd})"
end
response = begin response = begin
request.handle self, event.fd request.handle self, event.fd
rescue e : UserNotFound rescue e : UserNotFound
Baguette::Log.error "#{request_name} user not found" Baguette::Log.error "(fd #{ "%4d" % event.fd}) #{request_name} user not found"
AuthD::Response::Error.new "authorization error" AuthD::Response::Error.new "authorization error"
rescue e : AuthenticationInfoLacking rescue e : AuthenticationInfoLacking
Baguette::Log.error "#{request_name} lacking authentication info" Baguette::Log.error "(fd #{ "%4d" % event.fd}) #{request_name} lacking authentication info"
AuthD::Response::Error.new "authorization error" AuthD::Response::Error.new "authorization error"
rescue e : AdminAuthorizationException rescue e : AdminAuthorizationException
Baguette::Log.error "#{request_name} admin authentication failed" Baguette::Log.error "(fd #{ "%4d" % event.fd}) #{request_name} admin authentication failed"
AuthD::Response::Error.new "authorization error" AuthD::Response::Error.new "authorization error"
rescue e rescue e
Baguette::Log.error "#{request_name} generic error #{e}" Baguette::Log.error "(fd #{ "%4d" % event.fd}) #{request_name} generic error #{e}"
AuthD::Response::Error.new "unknown error" AuthD::Response::Error.new "unknown error"
end end
@ -142,10 +139,10 @@ class AuthD::Service < IPC
response_name = response.class.name.sub /^AuthD::Response::/, "" response_name = response.class.name.sub /^AuthD::Response::/, ""
if response.is_a? AuthD::Response::Error if response.is_a? AuthD::Response::Error
Baguette::Log.warning ">> #{response_name} (#{response.reason}) (TO: #{event.fd})" Baguette::Log.warning "fd #{ "%4d" % event.fd} (#{duration}) #{request_name} >> #{response_name} (#{response.reason})"
else else
if request_name != "KeepAlive" || @configuration.print_keepalive if request_name != "KeepAlive" || @configuration.print_keepalive
Baguette::Log.debug ">> #{response_name} (TO: #{event.fd}) (Total duration: #{duration})" Baguette::Log.debug "fd #{ "%4d" % event.fd} (#{duration}) #{request_name} >> #{response_name}"
end end
end end
end end