class RubyRed::Console

Constants

FORMAT_BOLD

The ANSI format code that makes something bold

FORMAT_RESET

The ANSI format code that resets formatting

MODES

The modes this logger can have. This is probably useless unless you want to write your own Logger

Attributes

fancy[W]

Public Class Methods

new(mode = :normal) click to toggle source
# File lib/rubyred/console.rb, line 7
def initialize(mode = :normal)
  self.mode = mode
  time = Time.now.strftime(CON_TIMESTAMP_FMT)
end

Public Instance Methods

log_exception(e) click to toggle source

Logs an exception to the console.

# File lib/rubyred/console.rb, line 49
def log_exception(e)
  error(e.inspect)
  e.backtrace.each { |line| error(line) }
end
mode=(value) click to toggle source
# File lib/rubyred/console.rb, line 38
def mode=(value)
  case value
    when :debug
      @log_modes = @enabled_modes = [:debug, :good, :info, :warn, :error, :out, :in]
    when :normal
      @log_modes = [:warn, :error]
      @enabled_modes = [:info, :warn, :error]
  end
end

Private Instance Methods

write(message, mode, timestamp) click to toggle source
# File lib/rubyred/console.rb, line 56
def write(message, mode, timestamp)
  puts "[#{mode[:format_code]}#{timestamp} #{mode[:long]}#{FORMAT_RESET}] #{message}"
end