1#!/usr/bin/ruby 2# Gives you information about the most recent crash for each application 3# that has crashed within the last 2 days 4 5$LogDir=ENV['HOME'] + '/Library/Logs/CrashReporter' 6$Days=1 7$StackCount=5 8 9files=`find #$LogDir -mtime -#$Days -type f | grep -v synergy` 10files.each { |filename| 11 filename.chop! 12 record = 0 13 date='' 14 stackTrace = [] 15 16 File.open(filename).readlines.each { |line| 17 #puts line 18 19 if line =~ /^Date.*(200.*)/ 20 date = $1 21 end 22 23 if line =~ /^Thread \d+ Crashed/ 24 record = 1 25 # reset the stack trace 26 stackTrace = [] 27 end 28 29 if record 30 stackTrace << line 31 record = record + 1 32 33 # stop recording after $StackCount lines 34 if record > ($StackCount + 2) 35 record = nil 36 end 37 end 38 } 39 40 puts File.basename(filename) + " - " + date 41 puts "===================================================" 42 stackTrace.each { |line| 43 puts line 44 } 45 puts "" 46} 47 48 49