class Stealth::Logger
Constants
- COLORS
Public Class Methods
color_code(code)
click to toggle source
# File lib/stealth/logger.rb, line 19 def self.color_code(code) COLORS.fetch(code) { raise(ArgumentError, "Color #{code} not supported.") } end
colorize(input, color:)
click to toggle source
# File lib/stealth/logger.rb, line 23 def self.colorize(input, color:) "\e[#{color_code(color)}m#{input}\e[0m" end
log(topic:, message:)
click to toggle source
# File lib/stealth/logger.rb, line 27 def self.log(topic:, message:) unless ENV['STEALTH_ENV'] == 'test' puts "#{print_topic(topic)} #{message}" end end
Also aliased as: l
print_topic(topic)
click to toggle source
# File lib/stealth/logger.rb, line 33 def self.print_topic(topic) topic_string = "[#{topic}]" case topic.to_sym when :session colorize(topic_string, color: :green) when :previous_session colorize(topic_string, color: :yellow) when :facebook, :twilio colorize(topic_string, color: :blue) when :smooch colorize(topic_string, color: :magenta) when :alexa colorize(topic_string, color: :light_cyan) when :catch_all colorize(topic_string, color: :red) else colorize(topic_string, color: :gray) end end