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

Adds spec for custom logger #356

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 2 additions & 4 deletions lib/savon/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,15 @@ def raise_errors(raise_errors)
def log(log)
if log
HTTPI.log = true
target = $stdout
else
HTTPI.log = false
windows = RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i
target = windows ? "NUL:" : "/dev/null"
@options[:logger] = Logger.new(target)
end

@options[:logger] = Logger.new(target)
end

# The logger to use. Defaults to a Savon::Logger instance.
# The logger to use. Defaults to a Logger instance.
def logger(logger)
@options[:logger] = logger
end
Expand Down
9 changes: 9 additions & 0 deletions spec/savon/options_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "spec_helper"
require "integration/support/server"
require "logger"

describe "Options" do

Expand Down Expand Up @@ -213,6 +214,14 @@
logger = new_client.globals[:logger]
expect(logger).to be_a(Logger)
end

it "allows a custom logger to be set" do
custom_logger = Logger.new($stdout)
c = new_client(logger: custom_logger, log: true)
logger = c.globals[:logger]

expect(logger).to be_equal(custom_logger)
end
end

context "global :log_level" do
Expand Down