From 3ecefeac6f07fc5d7d8a8990f86462f58af260a2 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Mon, 24 Feb 2025 15:18:05 +0000 Subject: [PATCH 1/2] fix: Add HTTP method to logging details - Included the HTTP method in the response log. - Set a default method value of 'GET' if not provided. - Ensured logs are sorted and cleaned up before final output. --- lib/data_services_api/service.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/data_services_api/service.rb b/lib/data_services_api/service.rb index cbab7e1..abe2a7a 100644 --- a/lib/data_services_api/service.rb +++ b/lib/data_services_api/service.rb @@ -52,6 +52,7 @@ def get_json(http_url, params, options) # rubocop:disable Metrics/MethodLength, source: URI.parse(http_url).path.split('/').last, timer: elapsed_time }), + method: response.env.method.upcase, path: URI.parse(http_url).path, query_string: query_string, request_status: 'processing', @@ -262,6 +263,7 @@ def log_message(log_fields, log_type = 'info') duration = (end_time - start_time) / 1000 if start_time # parse out the optional parameters and set defaults log_fields[:message] ||= log_fields[:response]&.body + log_fields[:method] ||= 'GET' log_fields[:request_time] ||= duration log_fields[:request_status] ||= 'completed' if log_fields[:status] == 200 log_fields[:start_time] = nil @@ -269,6 +271,8 @@ def log_message(log_fields, log_type = 'info') # Clear out nil values from the log fields logs = log_fields.compact + + logs.sort.to_h # Log the API responses at the appropriate level requested case log_type when 'error' From 8b716e966690dd3f1c9efdbafd9c1ecd18687087 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Mon, 24 Feb 2025 15:18:33 +0000 Subject: [PATCH 2/2] docs: Updated CHANGELOG for v1.5.2 - Included the HTTP method in response logs. - Set default method value to 'GET' if not specified. - Sorted and cleaned up logs before final output. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9976c37..40d2318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 1.5.2 - 2025-02 +- (Jon) Included the HTTP method in the response log. +- (Jon) Set a default method value of 'GET' if not provided. +- (Jon) Ensured logs are sorted and cleaned up before final output. - (Jon) Updated the instrumenter calls to include exceptions as a keyword argument for better clarity and consistency. [GH-465](https://github.com/epimorphics/ukhpi/issues/465)