Sha256: 6b2a02b905c3c2f0f65c56c46d8e949e63d9c61798726aacf498b2f62f65f6b8

Contents?: true

Size: 573 Bytes

Versions: 3

Compression:

Stored size: 573 Bytes

Contents

module Kirchhoff
  module Logger
    ANSI_CODES = {
      :red    => 31,
      :green  => 32,
      :yellow => 33,
      :blue   => 34,
      :gray   => 90
    }.freeze

    class << self
      def call(sym, text)
        label = case sym
        when :info then blue("INFO")
        when :fail then red("FAIL")
        end
        puts "[#{label}] #{text}"
      end

      private
        Kirchhoff::Logger::ANSI_CODES.each do |name, code|
          define_method(name) do |string|
            "\e[0;#{code};49m#{string}\e[0m"
          end
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kirchhoff-0.0.3 lib/kirchhoff/logger.rb
kirchhoff-0.0.2 lib/kirchhoff/logger.rb
kirchhoff-0.0.1 lib/kirchhoff/logger.rb