lib/ntail/log_line.rb in ntail-0.0.3 vs lib/ntail/log_line.rb in ntail-0.0.4
- old
+ new
@@ -41,10 +41,12 @@
def initialize(line)
@parsable = if NGINX_LOG_PATTERN.match(@raw_line = line)
@remote_address, @remote_user, @time_local, @request, @status, @body_bytes_sent, @http_referer, @http_user_agent, @proxy_addresses = $~.captures
if NGINX_REQUEST_PATTERN.match(@request)
+ # counter example (ie. HTTP request that cannot by parsed)
+ # 91.203.96.51 - - [21/Dec/2010:05:26:53 +0000] "-" 400 0 "-" "-"
@http_method, @uri, @http_version = $~.captures
end
if @proxy_addresses and NGINX_PROXY_PATTERN.match(@proxy_addresses)
@proxy_addresses = $~.captures.first.split(/, /)
end
@@ -70,11 +72,11 @@
:default
end
"%#{Sickill::Rainbow.enabled ? 15 + 9 : 15}s - %s - %s - %s" % [
remote_address.foreground(color),
status.foreground(color),
- uri.foreground(color),
+ (uri || "-").foreground(color),
to_agent_s.foreground(color)
]
end
COMPONENTS = [
@@ -370,6 +372,6 @@
# Internal Server Error 5xx
def self.server_error_status?(status) (status.to_s != NGINX_MAGIC_STATUS) and Net::HTTPResponse::CODE_TO_OBJ[status.to_s] <= Net::HTTPServerError ; end
def server_error_status?() self.class.server_error_status?(self.status) ; end
end # class LogLine
-end # module NginxTail
\ No newline at end of file
+end # module NginxTail