Sha256: 6f1ffdf3b388ac1433b7571d83a9882a21068a7b8349d392f5386d89ecd6e4dd

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

class Logi; end
module Logi::Logger
  module_function
  def log msg
    return if options[:quiet]
    puts msg
  end

  def   black text; color(30, text); end
  def     red text; color(31, text); end
  def   green text; color(32, text); end
  def  yellow text; color(33, text); end
  def    blue text; color(34, text); end
  def magenta text; color(35, text); end
  def    cyan text; color(36, text); end
  def   white text; color(37, text); end
  def color rgb, text
    if nocolor = options[:nocolor]
      text
    elsif nocolor.nil? && !$stdout.tty? # auto-detect
      text
    else
      "\e[#{rgb}m#{text}\e[0m"
    end
  end

  def strip_path path
    strip_home_path(strip_cwd_path(path))
  end

  def strip_home_path path
    path.sub(ENV['HOME'], '~')
  end

  def strip_cwd_path path
    path.sub(Dir.pwd, '.')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logi-0.1.0 lib/logi/logger.rb