Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Add script to filter unwanted output
Browse files Browse the repository at this point in the history
For use with cron jobs to stop them emailing every time the job runs due
to deprecation warnings and such.
  • Loading branch information
Wesley Moore committed Oct 16, 2012
1 parent dc694ae commit 75dd724
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions scripts/filter-stdout
@@ -0,0 +1,37 @@
#!/usr/bin/env ruby

ignore =
[/^\s*$/,
'DeprecationWarning',
'webhelpers.',
'from routes',
/JavaScript/i,
'import md5',
'from sha import'
]

$this_host = `hostname`.strip

def match_rule(l,rule)
case rule
when Regexp
return l.match(rule)
when String
return l.match(Regexp.quote(rule))
when Array
return rule.any? { |r| match_rule(l,r) }
when Hash
rule.each do |host, r|
next if !$this_host.match(host)
return true if match_rule(l,r)
end
else
puts "ERROR. Unknown rule : #{rule}"
end
false
end

STDIN.each do |l|
skip = match_rule(l,ignore)
puts l if !skip
end

0 comments on commit 75dd724

Please sign in to comment.