Last active
December 30, 2015 12:59
-
-
Save abevoelker/7833221 to your computer and use it in GitHub Desktop.
Hacky script to convert a Rails log file to timestamp-render time .tsv
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
IN = '/tmp/production.log' | |
OUT = '/tmp/render_time.tsv' | |
render_vals = File.read(IN).split("\n\n").map do |lines| | |
# render time | |
m = lines.match(/^Completed in (\d+)ms/) | |
next unless m | |
render_time = m.captures[0].to_i | |
# action and timestamp | |
m = lines.match(/^Processing (\S*) \(for \S* at ([^)]*)\)/) | |
next unless m | |
action, timestamp = m.captures[0], m.captures[1] | |
[action, timestamp, render_time] | |
end.compact | |
File.open(OUT, "w") do |f| | |
f.write(render_vals.map{|tuple| tuple.join("\t")}.join("\n")) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment