Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the provided Savon/custom logger to Faraday #1017

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/savon/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def configure_adapter
end

def configure_logging
connection.response(:logger, nil, headers: @globals[:log_headers], level: @globals[:logger].level) if @globals[:log]
connection.response(:logger, @globals[:logger], headers: @globals[:log_headers]) if @globals[:log]
end

protected
Expand Down
10 changes: 5 additions & 5 deletions spec/savon/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def to_s
end

it "silences Faraday as well" do
Faraday::Connection.any_instance.expects(:response).with(:logger, nil, {:headers => true, :level => 0}).never
Faraday::Connection.any_instance.expects(:response).never

new_client(:log => false)
end
Expand All @@ -346,7 +346,7 @@ def to_s
end

it "turns Faraday logging back on as well" do
Faraday::Connection.any_instance.expects(:response).with(:logger, nil, {:headers => true, :level => 0}).at_least_once
Faraday::Connection.any_instance.expects(:response).with(:logger, kind_of(Logger), {:headers => true}).at_least_once
new_client(:log => true)
end
end
Expand All @@ -367,10 +367,10 @@ def to_s
end

it "sets the logger of faraday connection as well" do
Faraday::Connection.any_instance.expects(:response).with(:logger, nil, {:headers => true, :level => 0}).at_least_once
custom_logger = Logger.new($stdout)
custom_logger.level = :fatal
Faraday::Connection.any_instance.expects(:response).with(:logger, custom_logger, {:headers => true}).at_least_once
mock_stdout {
custom_logger = Logger.new($stdout)

client = new_client(:endpoint => @server.url, :logger => custom_logger, :log => true)
client.call(:authenticate)
}
Expand Down