Skip to content

Instantly share code, notes, and snippets.

@tijmenb
Created October 1, 2011 00:44
Show Gist options
  • Save tijmenb/1255429 to your computer and use it in GitHub Desktop.
Save tijmenb/1255429 to your computer and use it in GitHub Desktop.
Color for Capistrano
require 'color-logger.rb'
require 'term/ansicolor'
class String
include Term::ANSIColor
end
module Capistrano
class Logger
def log(level, message, line_prefix=nil)
if level <= self.level
(RUBY_VERSION >= "1.9" ? message.lines : message).each do |line|
line = line.capitalize
if line_prefix
device.puts colorize("[#{line_prefix}] #{line.strip}", level)
else
device.puts colorize("#{line.strip}", level)
end
end
end
end
def colorize(str, level)
case level
when 0: return str.red # IMPORTANT
when 1: return str.yellow.on_black # INFO
when 2: return str.blue # DEBUG
when 3: return str.dark # TRACE
else return str
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment