Skip to content

Commit

Permalink
Merge pull request #363 from krishgopi/master
Browse files Browse the repository at this point in the history
Log the request and response inside CRM_Mailchimp_Exception
  • Loading branch information
cmolava authored Jun 14, 2024
2 parents 83b216e + 0315425 commit 89094d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CRM/Mailchimp/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public function __construct(CRM_Mailchimp_Api3 $api, $message_prefix='') {
$this->request = isset($api->request) ? clone($api->request) : NULL;
$this->response = isset($api->response) ? clone($api->response) : NULL;

// log the request & response in the error logs
CRM_Mailchimp_Utils::logErrors('Mailchimp Request', $this->request);
CRM_Mailchimp_Utils::logErrors('Mailchimp Response', $this->response);

if (isset($this->response->data->title)) {
$message = $message_prefix . 'Mailchimp API said: ' . $this->response->data->title
. (empty($this->response->data->detail) ? '' : " (" . $this->response->data->detail . ")");
Expand Down
14 changes: 14 additions & 0 deletions CRM/Mailchimp/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,20 @@ public static function checkDebug($description, $variable='VARIABLE_NOT_PROVIDED
}
}

/**
* Log the error message in mailchimp log file
*/
/*
* Function to log Errors in ConfigLog
*
* @param string $description - description to print in log
* @param array $variable - variable to print in log
*
*/
public static function logErrors($description = 'No description', $variable = array()) {
CRM_Core_Error::debug_var("Error : " . $description, $variable, TRUE, TRUE, 'mailchimp');
}

/**
* Access our cached data.
*/
Expand Down

0 comments on commit 89094d8

Please sign in to comment.