Sha256: 34bc5967ed1ff052356b88a9242f6eaa8dba876be0c1fcf532b7e062ad63cbb6

Contents?: true

Size: 908 Bytes

Versions: 4

Compression:

Stored size: 908 Bytes

Contents

module Empezar
  class EchoingFormatter
    attr_accessor :wrapee, :stdout

    def initialize wrapee, stdout
      @wrapee = wrapee
      @stdout = stdout
    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

4 entries across 4 versions & 1 rubygems

Version Path
empezar-0.4.1 lib/empezar/echoing_formatter.rb
empezar-0.4.0 lib/empezar/echoing_formatter.rb
empezar-0.3.1 lib/empezar/echoing_formatter.rb
empezar-0.3.0 lib/empezar/echoing_formatter.rb