lib/angelo.rb in angelo-0.1.12 vs lib/angelo.rb in angelo-0.1.13
- old
+ new
@@ -36,10 +36,13 @@
DEFAULT_PORT = 4567
DEFAULT_VIEW_DIR = 'views'
DEFAULT_PUBLIC_DIR = 'public'
+ DEFAULT_LOG_LEVEL = ::Logger::INFO
+ DEFAULT_RESPONSE_LOG_LEVEL = :info
+
DEFAULT_RESPONSE_HEADERS = {
CONTENT_TYPE_HEADER_KEY => HTML_TYPE
}
NOT_FOUND = 'Not Found'
@@ -52,20 +55,30 @@
DASH = '-'
EMPTY_STRING = ''
HALT_STRUCT = Struct.new :status, :body
+ class << self
+
+ attr_writer :response_log_level
+
+ def response_log_level
+ @response_log_level ||= DEFAULT_RESPONSE_LOG_LEVEL
+ end
+
+ end
+
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 % [
+ Celluloid::Logger.__send__ Angelo.response_log_level, LOG_FORMAT % [
remote_ip[],
request.method,
request.path,
request.query_string.nil? ? nil : '?'+request.query_string,
request.version,