From d1f257d275adf53fc285273cb51af3f4598be606 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 31 Oct 2017 17:03:03 +0100 Subject: [PATCH] FinalDestination should only log when verbose is enabled --- lib/file_helper.rb | 3 ++- lib/final_destination.rb | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/file_helper.rb b/lib/file_helper.rb index 10fa7bb0006..c8039bb9c55 100644 --- a/lib/file_helper.rb +++ b/lib/file_helper.rb @@ -36,7 +36,8 @@ class FileHelper dest = FinalDestination.new( url, max_redirects: follow_redirect ? 5 : 1, - skip_rate_limit: skip_rate_limit + skip_rate_limit: skip_rate_limit, + verbose: verbose ) uri = dest.resolve diff --git a/lib/final_destination.rb b/lib/final_destination.rb index 357700ee44b..b290cf83768 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -51,6 +51,7 @@ class FinalDestination @http_verb = @force_get_hosts.any? { |host| hostname_matches?(host) } ? :get : :head @cookie = nil @limited_ips = [] + @verbose = @opts[:verbose] || false end def self.connection_timeout @@ -93,7 +94,7 @@ class FinalDestination if @limit < 0 @status = :too_many_redirects - log(:warn, "FinalDestination could not resolve URL (too many redirects): #{@uri}") + log(:warn, "FinalDestination could not resolve URL (too many redirects): #{@uri}") if @verbose return nil end @@ -105,7 +106,7 @@ class FinalDestination end unless validate_uri - log(:warn, "FinalDestination could not resolve URL (invalid URI): #{@uri}") + log(:warn, "FinalDestination could not resolve URL (invalid URI): #{@uri}") if @verbose return nil end @@ -180,10 +181,10 @@ class FinalDestination @status = :failure @status_code = response.status - log(:warn, "FinalDestination could not resolve URL (status #{response.status}): #{@uri}") + log(:warn, "FinalDestination could not resolve URL (status #{response.status}): #{@uri}") if @verbose nil rescue Excon::Errors::Timeout - log(:warn, "FinalDestination could not resolve URL (timeout): #{@uri}") + log(:warn, "FinalDestination could not resolve URL (timeout): #{@uri}") if @verbose nil end