Sha256: cd184f1d9bfdf905fc2ac1d7690a6e03f2607c3005f748557249dd51195d2e1c

Contents?: true

Size: 519 Bytes

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
autowow-0.8.0 lib/autowow/log_formatter.rb
autowow-0.7.0 lib/autowow/log_formatter.rb
autowow-0.6.3 lib/autowow/log_formatter.rb
autowow-0.6.0 lib/autowow/log_formatter.rb