Sha256: fe2b8d81eb0c170ed44b7dc78ede762eae20e137c891198578d8d6078cc317a4

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

module RSqoot
  module Logger
    def logger(options = {records: [], uri: '', error: '', type: '', opts: {}})
      records = options[:records].nil? ? [] : options[:records]
      error   = options[:error]
      uri     = options[:uri]
      type    = options[:type]
      opts    = options[:opts]

      if defined? Rails
        if error.present?
          Rails.logger.info ">>> Error: #{error}"
        else
          Rails.logger.info ">>> Querying Sqoot API V2: #{type}"
          Rails.logger.info ">>> #{uri}"
          Rails.logger.info ">>> #{opts}"
          Rails.logger.info ">>> Hit #{records.count} records"
        end
      else
        if error.present?
          puts ">>> Error: #{error}"
          puts ""
        else
          puts ">>> Querying Sqoot API V2: #{type}"
          puts ""
          puts ">>> #{uri}"
          puts ""
          puts ">>> #{opts}"
          puts ""
          puts ">>> Hit #{records.count} records"
          puts ""
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rsqoot-0.5.2 lib/rsqoot/logger.rb