Class: Paraduct::ColoredLabelLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/paraduct/colored_label_logger.rb

Constant Summary collapse

SEVERITIES =
[:debug, :info, :warn, :error, :fatal]
COLORS =
[
  :cyan,
  :yellow,
  :green,
  :magenta,
  :red,
  :blue,
  :light,
  :cyan,
  :light_yellow,
  :light_green,
  :light_magenta,
  :light_red,
  :light_blue,
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label_name, logdev = STDOUT) ⇒ ColoredLabelLogger

Returns a new instance of ColoredLabelLogger.



3
4
5
6
7
8
# File 'lib/paraduct/colored_label_logger.rb', line 3

def initialize(label_name, logdev = STDOUT)
  super(logdev)
  color = Paraduct::ColoredLabelLogger.next_color
  @label = "[#{label_name.to_s.colorize(color)}]"
  @formatter = ActiveSupport::Logger::SimpleFormatter.new
end

Class Method Details

.next_colorObject



35
36
37
38
39
# File 'lib/paraduct/colored_label_logger.rb', line 35

def self.next_color
  @@color_index ||= -1
  @@color_index = (@@color_index + 1) % COLORS.length
  COLORS[@@color_index]
end