Sha256: 4cc446db675c084587b3bcc4213cd414a0054bc2e7d87e95305a4c825154279d

Contents?: true

Size: 692 Bytes

Versions: 7

Compression:

Stored size: 692 Bytes

Contents

class Radiosonde::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, log_id = nil)
      message = "[#{level.to_s.upcase}] #{message}" unless level == :info
      message << ": #{log_id}" if log_id
      message << ' (dry-run)' if @options && @options[:dry_run]
      logger = (@options && @options[:logger]) || Radiosonde::Logger.instance
      logger.send(level, message.send(color))
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
radiosonde-0.0.7 lib/radiosonde/logger.rb
radiosonde-0.0.6 lib/radiosonde/logger.rb
radiosonde-0.0.5 lib/radiosonde/logger.rb
radiosonde-0.0.4 lib/radiosonde/logger.rb
radiosonde-0.0.3 lib/radiosonde/logger.rb
radiosonde-0.0.2 lib/radiosonde/logger.rb
radiosonde-0.0.1 lib/radiosonde/logger.rb