Sha256: 96545880f8dd6dd5f55919fa7154f05a55c62c4df7265eaf7fa132bf551bb081

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

# encoding: utf-8
module Ayadn
  class Debug

    def self.skipped dic
      if Settings.options.timeline.debug
        Logs.rec.debug "SKIPPED: #{dic.keys.first.to_s.capitalize} => #{dic.values.first}"
      end
    end

    def self.http response, url
      if Settings.options.timeline.debug
        deb = "\n"
        deb << "+ HTTP\n"
        deb << "* t#{Time.now.to_i}\n"
        deb << "Url: #{url}\n"
        deb << "Code: #{response.code}\n"
        deb << "\n"
        puts deb.color(:green)
        Logs.rec.debug "HTTP/URL: #{url}"
        Logs.rec.debug "HTTP/HEADERS: #{response.headers}"
      end
    end

    def self.err error, stack
      # Logs.rec.debug "+DEBUG STACK: #{stack}"
      if Settings.options.timeline.debug
        puts "\nDEBUG:\n"
        puts error.inspect
        raise error
        # puts "\nSTACK:\n"
        # puts stack
        # puts "\n--*--\n\n"
      end
    end

    def self.stream(stream, options, target)
      if Settings.options.timeline.debug
        deb = "\n"
        deb << "+ STREAM\n"
        deb << "* t#{Time.now.to_i}\n"
        deb << "Options:\t#{options.inspect}\n"
        deb << "Target:\t\t#{target.inspect}\n"
        deb << "Posts:\t\t#{stream.posts.length}\n"
        deb << "Meta:\t\t#{stream.meta.input.inspect}\n"
        deb << "\n"
        puts deb.color(Settings.options.colors.debug)
        Logs.rec.debug "STREAM/META: #{stream.meta.input.inspect}"
        Logs.rec.debug "STREAM/OPTIONS: #{options.inspect}"
        Logs.rec.debug "STREAM/TARGET: #{target.inspect}"
        Logs.rec.debug "STREAM/POSTS: #{stream.posts.length}"
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ayadn-4.0.3 lib/ayadn/debug.rb
ayadn-4.0.2 lib/ayadn/debug.rb
ayadn-4.0.1 lib/ayadn/debug.rb
ayadn-4.0 lib/ayadn/debug.rb