Sha256: fab34fa93f4b2c37e91a3d824233d7443da3b5c75c9f7fcab7348b64b0b0cda9
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Xip class Logger COLORS = ::Hash[ black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, gray: 37, light_cyan: 96, white: 97 ].freeze def self.color_code(code) COLORS.fetch(code) { raise(ArgumentError, "Color #{code} not supported.") } end def self.colorize(input, color:) "\e[#{color_code(color)}m#{input}\e[0m" end def self.log(topic:, message:) puts "#{print_topic(topic)} #{message}" end def self.print_topic(topic) topic_string = "[#{topic}]" color = case topic.to_sym when :primary_session :green when :previous_session, :back_to_session :yellow when :facebook, :twilio, :bandwidth :blue when :smooch :magenta when :alexa :light_cyan when :catch_all :red when :user :white else :gray end colorize(topic_string, color: color) end class << self alias_method :l, :log end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xip-0.0.1 | lib/xip/logger.rb |