Sha256: ab13a1863f711fcb0dbeb71eca1555042fbbb497ba3f61b647dffefcecf941dd

Contents?: true

Size: 994 Bytes

Versions: 141

Compression:

Stored size: 994 Bytes

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'logger'
require 'pp'

my_logger = Logger.new STDOUT

my_logger.info "Logging can be used on the main HTTParty class. It logs redirects too."
HTTParty.get "http://google.com", logger: my_logger

my_logger.info '*' * 70

my_logger.info "It can be used also on a custom class."

class Google
  include HTTParty
  logger ::Logger.new STDOUT
end

Google.get "http://google.com"

my_logger.info '*' * 70

my_logger.info "The default formatter is :apache. The :curl formatter can also be used."
my_logger.info "You can tell which method to call on the logger too. It is info by default."
HTTParty.get "http://google.com", logger: my_logger, log_level: :debug, log_format: :curl

my_logger.info '*' * 70

my_logger.info "These configs are also available on custom classes."
class Google
  include HTTParty
  logger ::Logger.new(STDOUT), :debug, :curl
end

Google.get "http://google.com"

Version data entries

141 entries across 115 versions & 7 rubygems

Version Path
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.70 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.69 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.68 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.67 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.66 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.65 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.64 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.63 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb
harbr-0.1.62 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/logging.rb