Skip to content

Instantly share code, notes, and snippets.

@adparadise
Created December 9, 2011 01:36
Show Gist options
  • Save adparadise/1449695 to your computer and use it in GitHub Desktop.
Save adparadise/1449695 to your computer and use it in GitHub Desktop.
A simple script to colorize logs piped through it.
#!/usr/bin/env ruby
require 'rubygems'
require 'term/ansicolor'
ARGF.each_line do |line|
color = case line
when /^ERROR/ then Term::ANSIColor.red
when /^WARN/ then Term::ANSIColor.yellow
when /^INFO/ then Term::ANSIColor.green
else ""
end
STDOUT.write(color + line + Term::ANSIColor.reset)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment