Skip to content

Instantly share code, notes, and snippets.

@nowlinuxing
Created July 24, 2013 08:21
Show Gist options
  • Save nowlinuxing/6068865 to your computer and use it in GitHub Desktop.
Save nowlinuxing/6068865 to your computer and use it in GitHub Desktop.
A skelton script to transform Rails log
#!/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