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.12.3 lib/all/sugarcube/log.rb
sugarcube-2.12.2 lib/all/sugarcube/log.rb
sugarcube-2.12.1 lib/all/sugarcube/log.rb
sugarcube-2.12.0 lib/all/sugarcube/log.rb
sugarcube-2.11.1 lib/all/sugarcube/log.rb
sugarcube-2.11.0 lib/all/sugarcube/log.rb
sugarcube-2.10.0 lib/all/sugarcube/log.rb
sugarcube-2.9.1 lib/all/sugarcube/log.rb
sugarcube-2.8.2 lib/all/sugarcube/log.rb
sugarcube-2.8.1 lib/all/sugarcube/log.rb
sugarcube-2.8.0 lib/all/sugarcube/log.rb
sugarcube-2.7.1 lib/all/sugarcube/log.rb
sugarcube-2.7.0 lib/all/sugarcube/log.rb
sugarcube-2.6.0 lib/all/sugarcube/log.rb
sugarcube-2.5.0 lib/all/sugarcube/log.rb
sugarcube-2.4.2 lib/all/sugarcube/log.rb
sugarcube-2.4.1 lib/all/sugarcube/log.rb
sugarcube-2.4.0 lib/all/sugarcube/log.rb
sugarcube-2.3.0 lib/all/sugarcube/log.rb
sugarcube-2.2.0 lib/all/sugarcube/log.rb