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

Fix #74 Change some log levels from info to debug #75

Merged
merged 1 commit into from
Jan 4, 2018
Merged
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
change logging from info to debug to avoid leaking header secrets
in logs and avoid too much verbose information in level info log
  • Loading branch information
Matthieu Paret committed Jan 2, 2018
commit 79c132a4795d36f6ba82b09e14ea9d4fa6db9e69
30 changes: 15 additions & 15 deletions lib/fhir_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def fhir_headers(options = {})
end

def parse_reply(klass, format, response)
FHIR.logger.info "Parsing response with {klass: #{klass}, format: #{format}, code: #{response.code}}."
FHIR.logger.debug "Parsing response with {klass: #{klass}, format: #{format}, code: #{response.code}}."
return nil unless [200, 201].include? response.code
res = nil
begin
Expand Down Expand Up @@ -329,9 +329,9 @@ def get(path, headers)
body: response.body
}
if url.end_with?('/metadata')
FHIR.logger.info "GET - Request: #{req}, Response: [too large]"
FHIR.logger.debug "GET - Request: #{req}, Response: [too large]"
else
FHIR.logger.info "GET - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "GET - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
end
@reply = FHIR::ClientReply.new(req, res)
else
Expand Down Expand Up @@ -364,9 +364,9 @@ def get(path, headers)
response = e.response
end
if url.end_with?('/metadata')
FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: [too large]"
FHIR.logger.debug "GET - Request: #{response.request.to_json}, Response: [too large]"
else
FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding('UTF-8')}"
end
response.request.args[:path] = response.request.args[:url].gsub(@base_service_url, '')
headers = response.headers.each_with_object({}) { |(k, v), h| h[k.to_s.tr('_', '-')] = v.to_s; h }
Expand Down Expand Up @@ -410,12 +410,12 @@ def post(path, resource, headers)
headers: response.headers,
body: response.body
}
FHIR.logger.info "POST - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "POST - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
@reply = FHIR::ClientReply.new(req, res)
else
headers.merge!(@security_headers) if @use_basic_auth
@client.post(url, payload, headers) do |resp, request, result|
FHIR.logger.info "POST - Request: #{request.to_json}\nResponse:\nResponse Headers: #{scrubbed_response_headers(result.each_key {})} \nResponse Body: #{resp.force_encoding('UTF-8')}"
FHIR.logger.debug "POST - Request: #{request.to_json}\nResponse:\nResponse Headers: #{scrubbed_response_headers(result.each_key {})} \nResponse Body: #{resp.force_encoding('UTF-8')}"
request.args[:path] = url.gsub(@base_service_url, '')
res = {
code: result.code,
Expand Down Expand Up @@ -457,12 +457,12 @@ def put(path, resource, headers)
headers: response.headers,
body: response.body
}
FHIR.logger.info "PUT - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "PUT - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
@reply = FHIR::ClientReply.new(req, res)
else
headers.merge!(@security_headers) if @use_basic_auth
@client.put(url, payload, headers) do |resp, request, result|
FHIR.logger.info "PUT - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
FHIR.logger.debug "PUT - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
request.args[:path] = url.gsub(@base_service_url, '')
res = {
code: result.code,
Expand Down Expand Up @@ -504,13 +504,13 @@ def patch(path, patchset, headers)
headers: response.headers,
body: response.body
}
FHIR.logger.info "PATCH - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "PATCH - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
@reply = FHIR::ClientReply.new(req, res)
else
headers.merge!(@security_headers) if @use_basic_auth
begin
@client.patch(url, payload, headers) do |resp, request, result|
FHIR.logger.info "PATCH - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
FHIR.logger.debug "PATCH - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
request.args[:path] = url.gsub(@base_service_url, '')
res = {
code: result.code,
Expand All @@ -536,7 +536,7 @@ def patch(path, patchset, headers)
res = {
body: e.message
}
FHIR.logger.info "PATCH - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "PATCH - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.error "PATCH Error: #{e.message}"
@reply = FHIR::ClientReply.new(req, res)
end
Expand Down Expand Up @@ -572,12 +572,12 @@ def delete(path, headers)
headers: response.headers,
body: response.body
}
FHIR.logger.info "DELETE - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
FHIR.logger.debug "DELETE - Request: #{req}, Response: #{response.body.force_encoding('UTF-8')}"
@reply = FHIR::ClientReply.new(req, res)
else
headers.merge!(@security_headers) if @use_basic_auth
@client.delete(url, headers) do |resp, request, result|
FHIR.logger.info "DELETE - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
FHIR.logger.debug "DELETE - Request: #{request.to_json}, Response: #{resp.force_encoding('UTF-8')}"
request.args[:path] = url.gsub(@base_service_url, '')
res = {
code: result.code,
Expand All @@ -594,7 +594,7 @@ def head(path, headers)
url = URI(build_url(path)).to_s
FHIR.logger.info "HEADING: #{url}"
RestClient.head(url, headers) do |response, request, result|
FHIR.logger.info "HEAD - Request: #{request.to_json}, Response: #{response.force_encoding('UTF-8')}"
FHIR.logger.debug "HEAD - Request: #{request.to_json}, Response: #{response.force_encoding('UTF-8')}"
request.args[:path] = url.gsub(@base_service_url, '')
res = {
code: result.code,
Expand Down