Sha256: 636613200867a4653c4fba1fab15e7da50caa88dca20eab0d239816ca064d100

Contents?: true

Size: 590 Bytes

Versions: 9

Compression:

Stored size: 590 Bytes

Contents

module Blazing
  class Logger

    LOG_LEVELS =  [:info, :success, :warn, :error]

    def initialize(output = $stdout)
      @output = output
    end

    def messages
      @messages ||= []
    end

    def log(type, message)
      if LOG_LEVELS.include? type
        messages << Hash[:message => message, :type => type]
      else
        raise
      end
    end

    def report(type = nil)
      if type
        messages.select { |m| m[:type] == type }.each { |m| @output.puts m[:message] }
      else
        messages.each { |m| @output.puts m[:message] }
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blazing-0.0.16 lib/blazing/logger.rb
blazing-0.0.15 lib/blazing/logger.rb
blazing-0.0.14 lib/blazing/logger.rb
blazing-0.0.13 lib/blazing/logger.rb
blazing-0.0.12 lib/blazing/logger.rb
blazing-0.0.10 lib/blazing/logger.rb
blazing-0.0.9 lib/blazing/logger.rb
blazing-0.0.8 lib/blazing/logger.rb
blazing-0.0.7 lib/blazing/logger.rb