lib/percy.rb in percy-capybara-4.0.1 vs lib/percy.rb in percy-capybara-4.0.2

- old
+ new

@@ -64,10 +64,15 @@ end end def self._make_dom_snapshot(page) agent_js = self._get_agent_js + + if self._is_debug? + self._logger.info { "agent_js file: #{agent_js}" } + end + return unless agent_js begin page.execute_script(agent_js) dom_snapshot_js = <<-JS @@ -96,11 +101,15 @@ def self._is_agent_running? begin Net::HTTP.get(AGENT_HOST, '/percy/healthcheck', AGENT_PORT) return true - rescue + rescue => e + if self._is_debug? + self._logger.error { "Healthcheck failed, agent is not running: #{e}" } + end + return false end end # For Ruby style, require snake_case args but transform them into camelCase for percy-agent. @@ -113,7 +122,11 @@ options[json_key] = options[ruby_key] options.delete(ruby_key) end end return options + end + + def self._is_debug? + ENV['LOG_LEVEL'] == 'debug' end end