Log request methods and URLs to assist with troubleshooting

Created on 21 February 2024, 4 months ago

Problem/Motivation

Hi, when things go wrong, it can be very difficult to see what request triggered the error.

Blackbaud::requestResponse() output error messages and HTTP error codes, but the logging output does not indicate what request generated the error.

Proposed resolution

Either:
1. Add a debug level log for each request at time of request:

    try {
      // Try the request.
+      \Drupal::logger('Blackbaud SKY API')->debug('HTTP :type request to :url', [':type' => $type, ':url' => $this->getUrl()]);
      $response = $client->request($type, $this->getUrl(), $options);

The above added line could also be wrapped in a config check, like so:

+      if (\Drupal::service('config.manager')->getConfigFactory()->get('blackbaud_sky_api.settings')->get('debug')) {
+      \Drupal::logger('Blackbaud SKY API')->debug('HTTP :type request to :url', [':type' => $type, ':url' => $this->getUrl()]);
+      }
      $response = $client->request($type, $this->getUrl(), $options);

2. Or, to save log output, add method and url only to the various error messages.

Remaining tasks

1. Discuss preferred approach and
2. Post a merge request

User interface changes

none

API changes

none

Data model changes

none

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apotek

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024