Sha256: c231618726312540bdfae2a9ffcd3b516042d6687d14a1ea11edfa4aa810e020

Contents?: true

Size: 883 Bytes

Versions: 5

Compression:

Stored size: 883 Bytes

Contents

module MessageLogger
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    def log(msg, options = {})
      logmsg(msg, $stdout, options)
    end

    def errorlog(msg, options = {})
      logmsg(msg, $stderr, options)
    end

    private

    def logmsg(msg, output, options)
      return if @options and @options[:silent] == true
      if @options and not @options[:nocolor] == true
        case options[:color]
        when :blue
          output << "\033[0;36m#{msg}#{"\033[0m" if options[:clear]}"
        when :bluebold
          output << "\033[1;36m#{msg}#{"\033[0m" if options[:clear]}"
        when :red
          output << "\033[0;31m#{msg}#{"\033[0m" if options[:clear]}"
        when :green
          output << "\033[0;32m#{msg}#{"\033[0m" if options[:clear]}"
        end
      else
        output << msg
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
screwcap-0.3.5 lib/screwcap/message_logger.rb
screwcap-0.3.4 lib/screwcap/message_logger.rb
screwcap-0.3.3 lib/screwcap/message_logger.rb
screwcap-0.3.2 lib/screwcap/message_logger.rb
screwcap-0.3.1 lib/screwcap/message_logger.rb