It seems error logging is unable to work:
https://git.drupalcode.org/project/mailchimp_ecommerce/blob/8.x-1.x/mailchimp_ecommerce.module#L94
/**
* Logs an error message using watchdog, if enabled.
*
* @todo This function cannot run, the function "watchdog" is never defined.
*
* @param string $message
* The error message to log.
*/
function mailchimp_ecommerce_log_error_message($message) {
if (function_exists('watchdog')) {
\Drupal::logger('mailchimp_ecommerce')->error('%message', array(
'%message' => $message,
));
}
}
Notice the @todo. I am not entirely sure why we would want to have this function at all rather than just injecting the logger service where needed. I think that would offer more flexibility, as this is only logging errors, and there could be other places we would want logging. For instance, there are a lot of drupal_set_message where a log entry might be more appropriate.
How do we want to proceed here?
- Fix this function ( remove the check for 'watchdog' )
- Remove this function and inject the logger service
Comments
Comment #2
scottsawyerI went the dependency injection route. I also uncommented a couple of places there was logging. Please test.
Comment #3
scottsawyerForgot to update the test.
Comment #4
acbramley commentedThe failure is due to the fact that your mock logger needs the
getfunction mocked.Similar to how the messenger has the
addErrormethod mocked, you'll need to mockgeton the logger to return a mockLoggerChannelInterfaceComment #5
scottsawyerUpdated test
Comment #6
samuel.mortensonSetting to NW for test failures.
Comment #8
xenophyle commented