Sha256: b9eddcac29878200d10eb63ccabca4e240d5a4e2b9ead2b79fe225d35b6e3cb6

Contents?: true

Size: 681 Bytes

Versions: 18

Compression:

Stored size: 681 Bytes

Contents

require 'singleton'

# This class centralizes all communication to STDOUT
module Overcommit
  class Logger
    include Singleton

    attr_accessor :output

    def partial(*args)
      out.print *args
    end

    def log(*args)
      out.puts *args
    end

    def bold(str)
      color('1;37', str)
    end

    def error(str)
      color(31, str)
    end

    def success(str)
      color(32, str)
    end

    def warning(str)
      color(33, str)
    end

    def notice(str)
      color('1;33', str)
    end

    def out
      self.output ||= $stdout
    end

  private

    def color(code, str)
      log(out.isatty ? "\033[#{code}m#{str}\033[0m" : str)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
overcommit-0.5.0 lib/overcommit/logger.rb
overcommit-0.4.1 lib/overcommit/logger.rb
overcommit-0.4.0 lib/overcommit/logger.rb
overcommit-0.3.2 lib/overcommit/logger.rb
overcommit-0.3.1 lib/overcommit/logger.rb
overcommit-0.3.0 lib/overcommit/logger.rb
overcommit-0.2.6 lib/overcommit/logger.rb
overcommit-0.2.5 lib/overcommit/logger.rb
overcommit-0.2.4 lib/overcommit/logger.rb
overcommit-0.2.3 lib/overcommit/logger.rb
overcommit-0.2.2 lib/overcommit/logger.rb
overcommit-0.2.1 lib/overcommit/logger.rb
overcommit-0.2.0 lib/overcommit/logger.rb
overcommit-0.1.11 lib/overcommit/logger.rb
overcommit-0.1.10 lib/overcommit/logger.rb
overcommit-0.1.9 lib/overcommit/logger.rb
overcommit-0.1.8 lib/overcommit/logger.rb
overcommit-0.1.7 lib/overcommit/logger.rb