123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::ColorizeLogging

Do not use. This module is for internal use only.

Constant Summary

Class Method Summary

Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

append_features, prepend_features

Instance Method Summary

Instance Method Details

#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.

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 52

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

#colorize_logging

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 66

def colorize_logging
  ActiveSupport.colorize_logging
end

#debug(progname = nil, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 29

def debug(progname = nil, &block)
  logger.debug(progname, &block) if logger
end

#error(progname = nil, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 37

def error(progname = nil, &block)
  logger.error(progname, &block) if logger
end

#fatal(progname = nil, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 41

def fatal(progname = nil, &block)
  logger.fatal(progname, &block) if logger
end

#info(progname = nil, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 25

def info(progname = nil, &block)
  logger.info(progname, &block) if logger
end

#mode_from(options)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 60

def mode_from(options)
  modes = MODES.values_at(*options.compact_blank.keys)

  "\e[#{modes.join(";")}m" if modes.any?
end

#unknown(progname = nil, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 45

def unknown(progname = nil, &block)
  logger.unknown(progname, &block) if logger
end

#warn(progname = nil, &block)

[ GitHub ]

  
# File 'activesupport/lib/active_support/colorize_logging.rb', line 33

def warn(progname = nil, &block)
  logger.warn(progname, &block) if logger
end