Created
July 24, 2013 08:21
-
-
Save nowlinuxing/6068865 to your computer and use it in GitHub Desktop.
A skelton script to transform Rails log
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
#!/usr/bin/env ruby | |
buf = {} | |
ARGF.readlines.each do |l| | |
case l.chomp | |
when /^Started ([^\s]+) "([^\s]+)" .* at ([-0-9]+) ([:0-9]+).*/ | |
_, method, path, date, time = Regexp.last_match.to_a | |
buf.merge!(:method => method, :path => path, :date => date, :time => time) | |
when /^Completed/ | |
puts "%s %s %s" % [buf[:time], buf[:method], buf[:path]] | |
when /^$/ | |
# nop | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment