Created
October 1, 2011 00:44
-
-
Save tijmenb/1255429 to your computer and use it in GitHub Desktop.
Color for Capistrano
This file contains 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 'color-logger.rb' |
This file contains 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 '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