lib/angelo.rb in angelo-0.1.0 vs lib/angelo.rb in angelo-0.1.1

- old
+ new

@@ -33,18 +33,28 @@ NOT_FOUND = 'Not Found' LOG_FORMAT = '%s - - "%s %s%s HTTP/%s" %d %s' def self.log connection, request, socket, status, body_size = '-' + + remote_ip = ->{ + if socket.nil? + connection.remote_ip rescue 'unknown' + else + socket.peeraddr(false)[3] + end + } + Celluloid::Logger.debug LOG_FORMAT % [ - socket.nil? ? connection.remote_ip : socket.peeraddr(false)[3], + remote_ip[], request.method, request.path, request.query_string.nil? ? nil : '?'+request.query_string, request.version, Symbol === status ? HTTP::Response::SYMBOL_TO_STATUS_CODE[status] : status, body_size ] + end end require 'angelo/version'