Sha256: 3867371ac1fd4abe5e9fec97184155ba42f8f05f82152a53946618c2a64f5228

Contents?: true

Size: 868 Bytes

Versions: 5

Compression:

Stored size: 868 Bytes

Contents

module Empezar
  class EchoingFormatter
    attr_accessor :wrapee

    def initialize wrapee
      @wrapee = wrapee
    end

    def call severity, datetime, progname, message
      case severity
        when Logger::Severity::FATAL, "FATAL"
          $stdout.puts Term::ANSIColor.bold Term::ANSIColor.red message
        when Logger::Severity::ERROR, "ERROR"
          $stdout.puts Term::ANSIColor.red message
        when Logger::Severity::WARN, "WARN"
          $stdout.puts Term::ANSIColor.yellow message
        when Logger::Severity::INFO, "INFO"
          $stdout.puts Term::ANSIColor.blue message
        when Logger::Severity::DEBUG, "DEBUG"
          $stdout.puts Term::ANSIColor.dark message
        when Logger::Severity::UNKNOWN, "UNKNOWN"
          $stdout.puts message
      end

      wrapee.call severity, datetime, progname, message
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
empezar-0.2.0 lib/empezar/echoing_formatter.rb
empezar-0.1.3 lib/empezar/echoing_formatter.rb
empezar-0.1.2 lib/empezar/echoing_formatter.rb
empezar-0.1.1 lib/empezar/echoing_formatter.rb
empezar-0.1.0 lib/empezar/echoing_formatter.rb