class FTest::ColoredLogger
Constants
- ANSI_COLORS
- DEFAULT_PALETTE
Attributes
palette[R]
Public Class Methods
new(io, palette = DEFAULT_PALETTE)
click to toggle source
# File lib/ftest/colored_logger.rb, line 16 def initialize io, palette = DEFAULT_PALETTE @logger = Logger.new io @palette = palette end
Public Instance Methods
bg(*args)
click to toggle source
# File lib/ftest/colored_logger.rb, line 51 def bg *args col :bg, *args end
col(fgbg, color_code, intensity_code, str)
click to toggle source
# File lib/ftest/colored_logger.rb, line 55 def col fgbg, color_code, intensity_code, str color_num = ANSI_COLORS.index color_code intensity_num = { :normal => 0, :bright => 1 }.fetch intensity_code fgbg_num = { :fg => 3, :bg => 4 }.fetch fgbg "\e[#{fgbg_num}#{color_num};#{intensity_num}m#{str}\e[0m" end
fg(*args)
click to toggle source
# File lib/ftest/colored_logger.rb, line 47 def fg *args col :fg, *args end
format(log_level, msg)
click to toggle source
# File lib/ftest/colored_logger.rb, line 42 def format log_level, msg formatter = palette.fetch log_level instance_exec msg, &formatter end