Sha256: 8514afc484d8d2c99de2062cf90abb4312c57caf130befccdc57109b7094188d

Contents?: true

Size: 519 Bytes

Versions: 17

Compression:

Stored size: 519 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

17 entries across 17 versions & 1 rubygems

Version Path
autowow-0.17.1 lib/autowow/log_formatter.rb
autowow-0.17.0 lib/autowow/log_formatter.rb
autowow-0.16.1 lib/autowow/log_formatter.rb
autowow-0.16.0 lib/autowow/log_formatter.rb
autowow-0.15.0 lib/autowow/log_formatter.rb
autowow-0.12.1 lib/autowow/log_formatter.rb
autowow-0.12.0 lib/autowow/log_formatter.rb
autowow-0.11.2 lib/autowow/log_formatter.rb
autowow-0.11.1 lib/autowow/log_formatter.rb
autowow-0.11.0 lib/autowow/log_formatter.rb
autowow-0.10.1 lib/autowow/log_formatter.rb
autowow-0.9.6 lib/autowow/log_formatter.rb
autowow-0.9.5 lib/autowow/log_formatter.rb
autowow-0.9.4 lib/autowow/log_formatter.rb
autowow-0.9.3 lib/autowow/log_formatter.rb
autowow-0.9.2 lib/autowow/log_formatter.rb
autowow-0.9.1 lib/autowow/log_formatter.rb