Created
October 8, 2014 17:03
-
-
Save rwrrll/ef1237f9777e04d35531 to your computer and use it in GitHub Desktop.
Really quick and dirty hack to "parse" Rails log files looking for a request/response pair.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filename = ARGV.first | |
puts "Opening #{filename}" | |
file = File.open(filename) | |
puts "Reading contents" | |
contents = file.read.encode('UTF-8', invalid: :replace) | |
puts "Splitting into requests" | |
requests = contents.split("\n\n\n") | |
puts "Found #{requests.length} requests" | |
puts "Looking for matches" | |
matches = requests.select do |request| | |
lines = request.split("\n") | |
lines.first.match(/^Started GET "\/" for/) && !lines.last.match(/^Completed 200/) | |
end | |
puts "Found #{matches.length} matches" | |
matches.each do |match| | |
puts "\n\n" | |
puts match | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment