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 53

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 67

def colorize_logging
  ActiveSupport.colorize_logging
end

#debug(progname = nil, &block)

[ GitHub ]

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

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 38

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 42

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 26

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 61

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 46

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 34

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