lib/angelo/responder.rb in angelo-0.0.9 vs lib/angelo/responder.rb in angelo-0.1.0
- old
+ new
@@ -1,5 +1,7 @@
+require 'date'
+
module Angelo
class Responder
include Celluloid::Logger
@@ -60,11 +62,13 @@
rescue => e
handle_error e
end
def handle_error _error, report = true
- @connection.respond :internal_server_error, headers, error_message(_error)
+ err_msg = error_message _error
+ Angelo.log @connection, @request, nil, :internal_server_error, err_msg.size
+ @connection.respond :internal_server_error, headers, err_msg
@connection.close
if report
error "#{_error.class} - #{_error.message}"
::STDERR.puts _error.backtrace
end
@@ -112,9 +116,10 @@
@body
when Hash
raise 'html response requires String' if respond_with? :html
@body.to_json if respond_with? :json
end
+ Angelo.log @connection, @request, nil, :ok, @body.size
@connection.respond :ok, headers, @body
rescue => e
handle_error e, false
end