#!/usr/bin/env ruby
text = ''
completed = false
total = 0
good = 0
ARGF.each do |l|
if l =~ /^Processing /
puts text if completed == false and text.size > 0
text = ''
completed = false
total += 1
elsif l =~ /^Completed /
completed = true
good += 1
end
text << l
end
puts text if completed == false and text.size > 0
$stderr.puts "Read #{total} transactions, #{total - good} were errors"
To use it you do this: striplog.rb development.log > development.log.errors. It will print out a summary line at the end to show you how many errors it found
No comments:
Post a Comment