Module: CrashLog::Logging::ClassMethods

Included in:
CrashLog
Defined in:
lib/crash_log/logging.rb

Instance Method Summary collapse

Instance Method Details

#colorize(color, text) ⇒ Object



34
35
36
# File 'lib/crash_log/logging.rb', line 34

def colorize(color, text)
  "\e[#{ANSI[color]}m#{text}\e[0m"
end

#log_exception(exception) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/crash_log/logging.rb', line 38

def log_exception(exception)
  logger.error("#{exception.class.name}: #{exception.message}")
  exception.backtrace.each { |line| logger.error(line) } if exception.backtrace
rescue Exception => e
  puts '--- FATAL ---'
  puts 'an exception occured while logging an exception'
  puts e.message, e.backtrace
  puts exception.message, exception.backtrace
end

#prefix(string) ⇒ Object



30
31
32
# File 'lib/crash_log/logging.rb', line 30

def prefix(string)
  [CrashLog::LOG_PREFIX, string].join(' ')
end