instance method
color
Ruby on Rails 8.1.2
Since v3.0.20 PrivateSignature
color(text, color, mode_options = {})
Set color by using a symbol or one of the defined constants. Set modes by specifying bold, italic, or underline options. Inspired by Highline, this method will automatically clear formatting at the end of the returned String.
Parameters
-
textreq -
colorreq -
mode_optionsopt = {}
Source
# File activesupport/lib/active_support/log_subscriber.rb, line 166
def color(text, color, mode_options = {}) # :doc:
return text unless colorize_logging
color = self.class.const_get(color.upcase) if color.is_a?(Symbol)
mode = mode_from(mode_options)
clear = "\e[#{MODES[:clear]}m"
"#{mode}#{color}#{text}#{clear}"
end
Defined in activesupport/lib/active_support/log_subscriber.rb line 166
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::LogSubscriber