class Outlog::ConsoleLogger
Constants
- CODEMAP
Mapping of color/style names to ANSI control values
- LEVELMAP
Map of log levels to colors
Public Instance Methods
output(hash)
click to toggle source
# File lib/outlog/console_logger.rb, line 26 def output hash arr = [hash[:message]] hash.each_pair { |k,v| next if %i[ ts level environment hostname pid message ].include? k arr << " #{k}=" arr << JSON.dump(v) } color = LEVELMAP[hash[:level]] || :green arr.unshift "\e[#{CODEMAP[color]}m" arr << "\e[#{CODEMAP[:normal]}m" puts arr.join $stdout.flush end