Created
June 13, 2011 22:00
-
-
Save burtlo/1023828 to your computer and use it in GitHub Desktop.
Generic Indy Log Parsing
This file contains hidden or 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
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