Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created June 13, 2011 22:00
Show Gist options
  • Save burtlo/1023828 to your computer and use it in GitHub Desktop.
Save burtlo/1023828 to your computer and use it in GitHub Desktop.
Generic Indy Log Parsing
require 'rubygems'
require 'Indy'
custom_pattern = /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s*(?:\[[^\]]+\])\s*(INFO|WARN|ERROR)\s*(.+)$/
results = Indy.search("file.log").with([custom_pattern,:time,:severity,:message]).like(:severity => '(?:WARN|ERROR)')
f = File.open('investigate.log','w') do |f|
results.each do |result|
f.write("#{result.line}\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment