Sha256: 6d4b2a69fbbf5d1cc82addc506f818c09254a0b9ad3242d27fe0abe99aed70bb

Contents?: true

Size: 866 Bytes

Versions: 26

Compression:

Stored size: 866 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, options = {})
      global_options = @options || {}
      message = "#{@object_identifier}: #{message}" if @object_identifier
      message = "[#{level.to_s.upcase}] #{message}" unless level == :info

      if global_options[:dry_run] and options[:dry_run] != false
        message << ' (dry-run)' if global_options[:dry_run]
      end

      message = message.send(options[:color]) if options[:color]
      logger = global_options[:logger] || Gratan::Logger.instance
      logger.send(level, message)
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
gratan-0.3.2 lib/gratan/logger.rb
gratan-0.3.1 lib/gratan/logger.rb
gratan-0.3.1.beta4 lib/gratan/logger.rb
gratan-0.3.1.beta3 lib/gratan/logger.rb
gratan-0.3.1.beta2 lib/gratan/logger.rb
gratan-0.3.1.beta lib/gratan/logger.rb
gratan-0.3.0 lib/gratan/logger.rb
gratan-0.3.0.beta lib/gratan/logger.rb
gratan-0.2.9 lib/gratan/logger.rb
gratan-0.2.9.beta3 lib/gratan/logger.rb
gratan-0.2.9.beta2 lib/gratan/logger.rb
gratan-0.2.9.beta lib/gratan/logger.rb
gratan-0.2.8 lib/gratan/logger.rb
gratan-0.2.8.beta3 lib/gratan/logger.rb
gratan-0.2.8.beta2 lib/gratan/logger.rb
gratan-0.2.8.beta lib/gratan/logger.rb
gratan-0.2.7 lib/gratan/logger.rb
gratan-0.2.6 lib/gratan/logger.rb
gratan-0.2.5 lib/gratan/logger.rb
gratan-0.2.4 lib/gratan/logger.rb