Sha256: 1f55c6d1e4052001379cc4d6e1b4f37da1cea9a0436d976c9724225226f9e186

Contents?: true

Size: 740 Bytes

Versions: 11

Compression:

Stored size: 740 Bytes

Contents

class Lbrt::Logger < ::Logger
  include Singleton

  def initialize
    super($stdout)

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

    self.level = INFO
  end

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

  module Helper
    def log(level, message, opts = {})
      global_options = (@options || {}).dup
      global_options.delete(:color)
      opts = global_options.merge(opts)

      message = "[#{level.to_s.upcase}] #{message}" unless level == :info
      message << ' (dry-run)' if opts[:dry_run]
      message = message.send(opts[:color]) if opts[:color]

      logger = opts[:logger] || Lbrt::Logger.instance
      logger.send(level, message)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lbrt-0.2.1 lib/lbrt/logger.rb
lbrt-0.2.0 lib/lbrt/logger.rb
lbrt-0.1.9 lib/lbrt/logger.rb
lbrt-0.1.8 lib/lbrt/logger.rb
lbrt-0.1.7 lib/lbrt/logger.rb
lbrt-0.1.6 lib/lbrt/logger.rb
lbrt-0.1.5 lib/lbrt/logger.rb
lbrt-0.1.4 lib/lbrt/logger.rb
lbrt-0.1.3 lib/lbrt/logger.rb
lbrt-0.1.1 lib/lbrt/logger.rb
lbrt-0.1.0 lib/lbrt/logger.rb