Sha256: e64028ea2eafffffdc2b2c1f5a7b65eb3f7d20f22d8440e1c19520f0b6b8e323

Contents?: true

Size: 1017 Bytes

Versions: 8

Compression:

Stored size: 1017 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 "httparty.log"

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 "httparty.log"
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 wich 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("httparty.log"), :debug, :curl
end

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

Version data entries

8 entries across 7 versions & 3 rubygems

Version Path
httparty-0.14.0 examples/logging.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/1.9.1/gems/httparty-0.13.7/examples/logging.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/2.0.0/gems/httparty-0.13.7/examples/logging.rb
httparty-0.13.7 examples/logging.rb
httparty-0.13.6 examples/logging.rb
httpserious-0.13.5.lstoll1 examples/logging.rb
httparty-0.13.5 examples/logging.rb
httparty-0.13.4 examples/logging.rb