Sha256: 2c4d90b1b6943691e13894140b48f5078f0bdd9bee0856159a38c41e6d841b01

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module RSqoot
  module Logger

    # Add logger support, easy for log monitor when running your app
    # Output errors and valid records count
    # TODO add color support
    #
    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

2 entries across 2 versions & 1 rubygems

Version Path
rsqoot-0.5.4 lib/rsqoot/logger.rb
rsqoot-0.5.3 lib/rsqoot/logger.rb