Sha256: 8189c59662e76cc55e5a1ea60ab6cacab525b4de0a431d8edb8e4bb668a3d453

Contents?: true

Size: 671 Bytes

Versions: 4

Compression:

Stored size: 671 Bytes

Contents

class Gratan::Logger < ::Logger
  include Singleton

  def initialize
    super($stdout)

    self.formatter = proc do |severity, datetime, progname, msg|
      "#{msg}\n"
    end

    self.level = Logger::INFO
  end

  def set_debug(value)
    self.level = value ? Logger::DEBUG : Logger::INFO
  end

  module Helper
    def log(level, message, color = nil)
      options = @options || {}
      message = "[#{level.to_s.upcase}] #{message}" unless level == :info
      message << ' (dry-run)' if options[:dry_run]
      message = message.send(color) if color
      logger = options[:logger] || Gratan::Logger.instance
      logger.send(level, message)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gratan-0.1.3 lib/gratan/logger.rb
gratan-0.1.2 lib/gratan/logger.rb
gratan-0.1.1 lib/gratan/logger.rb
gratan-0.1.0 lib/gratan/logger.rb