Sha256: 640db705b8959d24c9811ed95689d7a5d61cf80063bd98a32ffaf752709b7e0a

Contents?: true

Size: 884 Bytes

Versions: 29

Compression:

Stored size: 884 Bytes

Contents

module SugarCube
  module_function

  def log(message=nil)
    @log ||= []

    if message.nil?
      return @log
    end

    if suppress?
      log << message
    elsif log?
      stderr(message)
    end

    self
  end

  def flush_log(notification=nil)
    return unless @log && ! @log.empty?

    output = "SugarCube recorded the following warnings:"
    @log.uniq.each do |message|
      output << "\n"
      output << message
    end
    NSLog(output)
    @log = nil
  end

  def log?(value=nil)
    if value.nil?
      if @logging.nil?
        @logging = (RUBYMOTION_ENV == 'development')
      end
      @logging
    else
      @logging = value
      unless @logging
        @log = nil
      end
    end
  end

  def suppress?(value=nil)
    if value.nil?
      @suppress
    else
      @suppress = value
      unless @suppress
        @log = nil
      end
    end
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
sugarcube-2.1.5 lib/all/sugarcube/log.rb
sugarcube-2.1.4 lib/all/sugarcube/log.rb
sugarcube-2.1.3 lib/all/sugarcube/log.rb
sugarcube-2.1.2 lib/all/sugarcube/log.rb
sugarcube-2.1.1 lib/all/sugarcube/log.rb
sugarcube-2.1.0 lib/all/sugarcube/log.rb
sugarcube-2.0.2 lib/all/sugarcube/log.rb
sugarcube-2.0.1 lib/all/sugarcube/log.rb
sugarcube-2.0.0 lib/all/sugarcube/log.rb