def parse( line )
_, remote_addr, status, request, size, referrer, http_user_agent, http_x_forwarded_for = /^([^\s]+) - (\d+) \"(.+)\" (\d+) \"(.*)\" \"([^\"]*)\" \"(.*)\"/.match(line).to_a
print line
print request
if request && request != nil
_, referrer_host, referrer_url = /^http[s]?:\/\/([^\/]+)(\/.*)/.match(referrer).to_a if referrer
method, full_url, _ = request.split(' ')
in parse: private method 'split' called for nil:NilClass (NoMethodError)
So, I understand that it calls splitnot for the string, but for nil. This part analyzes the web server log. But I can’t understand why he gets it nil. As I understand it, this is null.
Some of the subpatterns in regex failed? So is this a web server error that sometimes generates invalid logging lines?
By the way, how to write to a file in ruby? I cannot read this cmd window correctly under the windows.
source
share