Sha256: de31de700db75f3095557b6252de3bbe42e791615f8ee0e52b94cc242ce6d6d7

Contents?: true

Size: 544 Bytes

Versions: 8

Compression:

Stored size: 544 Bytes

Contents

require "pastel"

module Autowow
  class LogFormatter
    def self.beautify(severity, msg)
      log_msg = msg.to_s.end_with?($/) ? msg : "#{msg}#{$/}"
      log_msg = " $ #{log_msg}" if severity.eql?("DEBUG")
      color(severity, log_msg)
    end

    def self.color(severity, msg)
      pastel = Pastel.new
      case severity
      when "DEBUG"
        pastel.yellow(msg)
      when "WARN"
        pastel.red(msg)
      when "ERROR"
        pastel.bright_red(msg)
      else
        msg
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
autowow-0.14.2 lib/autowow/log_formatter.rb
autowow-0.14.1 lib/autowow/log_formatter.rb
autowow-0.14.0 lib/autowow/log_formatter.rb
autowow-0.13.2 lib/autowow/log_formatter.rb
autowow-0.13.1 lib/autowow/log_formatter.rb
autowow-0.13.0 lib/autowow/log_formatter.rb
autowow-0.9.0 lib/autowow/log_formatter.rb
autowow-0.8.1 lib/autowow/log_formatter.rb