Permalink
Browse files

Merge pull request #9 from kcrayon/master

:replace feature
  • Loading branch information...
2 parents 8d0d0ac + df76ace commit f3bb4569b928e9083eb0daa5913994b157273e90 @stjernstrom committed May 28, 2012
Showing with 6 additions and 2 deletions.
  1. +1 −0 README.rdoc
  2. +1 −0 lib/capistrano_colors/configuration.rb
  3. +4 −2 lib/capistrano_colors/logger.rb
View
@@ -36,6 +36,7 @@ When capistrano_colors is included in your deploy.rb capistrano output gets nice
* :attribute - Special effect (:underline, :reverse, :blink)
* :level - Specify if this matcher should be bound to some of capistranos log levels (info,debug,...)
* :prepend - Text to be prepended to the output
+ * :replace - Text to replace the matched regular expression.
* :timestamp - Show current time with the output
=== match
@@ -52,6 +52,7 @@ class Configuration
# == Text alterations
#
# :prepend gives static text to be prepended to the output
+ # :replace replaces the matched text in the output
# :timestamp adds the current time before the output
#
def colorize(options)
@@ -38,12 +38,13 @@ def log(level, message, line_prefix=nil) #:nodoc:
if (filter[:level] == level || filter[:level].nil?)
if message =~ filter[:match] || line_prefix =~ filter[:match]
- color = filter[:color]
+ color = filter[:color] if filter[:color]
attribute = filter[:attribute]
+ message.gsub!(filter[:match], filter[:replace]) if filter[:replace]
message = filter[:prepend] + message unless filter[:prepend].nil?
message = message + filter[:append] unless filter[:append].nil?
message = Time.now.strftime('%T') + ' ' + message if filter[:timestamp]
- break
+ break unless filter[:replace]
end
end
@@ -61,6 +62,7 @@ def log(level, message, line_prefix=nil) #:nodoc:
def self.add_color_matcher( options ) #:nodoc:
@@color_matchers.push( options )
+ @@sorted_color_matchers = nil
end
def colorize(message, color, attribute, nl = "\n")

0 comments on commit f3bb456

Please sign in to comment.