Skip to content
Snippets Groups Projects
Commit 1f754cd1 authored by Paul Mrvik's avatar Paul Mrvik
Browse files

Issue #3488512 by globexplorer: Better debug logging for problems sending notifications

parent 9e101ce9
No related branches found
No related tags found
No related merge requests found
......@@ -118,10 +118,6 @@ function conditional_notification_cron() {
$results = $query->execute();
\Drupal::logger('debug')->warning('Whats going on here!!!');
\Drupal::logger('debug')->warning('cron results<pre><code>' . print_r($results, TRUE) . '</code></pre>');
if (!empty($results)) {
$entities = \Drupal::entityTypeManager()->getStorage('conditional_notification_log')->loadMultiple($results);
foreach ($entities as $entity) {
......@@ -138,6 +134,9 @@ function conditional_notification_cron() {
'entity_type' => $entity->entity_type->value,
'notification_id' => $entity->notification_id->target_id,
];
\Drupal::logger('conditional_notification')->debug('Conditional notification data at cron processing! <pre><code>' . print_r($data, TRUE) . '</code></pre>');
}
}
}
......@@ -153,4 +152,4 @@ function conditional_notification_cron() {
}
}
}
}
\ No newline at end of file
}
......@@ -89,14 +89,10 @@ class EntityTypeInfo implements ContainerInjectionInterface {
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type instanceof ContentEntityType) {
$supported_entities = $this->config->get('supported_entities');
$bundle = $entity_type->getBundleOf();
$type = $entity_type_id;
if (!empty($supported_entities)) {
if (in_array("$type:$bundle",$supported_entities)) {
$entity_link = $entity_type->getLinkTemplate('edit-form');
......@@ -189,8 +185,6 @@ class EntityTypeInfo implements ContainerInjectionInterface {
$operations = [];
if ($this->currentUser->hasPermission('administer conditional_notification')) {
dump($entity);
if ($entity->hasLinkTemplate('conditional-notification-default-templates')) {
$operations['conditional-notification'] = [
'title' => $this->t('Conditional Notification'),
......
......@@ -102,6 +102,18 @@ final class NotificationFactory {
}
$this->addToQueue($data);
}
else {
$debug_data = [
'notification_id' => $notification->getId(),
'entity_type' => $entity->getEntityTypeId(),
'entity_id' => $entity->id(),
];
$debug = json_encode($debug_data);
$this->getLogger('conditional_notification')
->warning('A condition was unsuccessful: Debug Info: @debug.', [
'@debug' => $debug
]);
}
}
}
}
......@@ -116,6 +128,7 @@ final class NotificationFactory {
* @return void
*/
public function createNotificationsOnCron($data): void {
if (!empty($data)) {
$this->addToQueue($data);
// Set to processed as it now lives in queue.
......@@ -153,7 +166,12 @@ final class NotificationFactory {
}
catch (\Exception $exception) {
$message = $exception->getMessage();
$this->getLogger('conditional_notification')->warning('Problem updating conditional notification log: @message',['@message' => $message]);
$debug = json_encode($conditions);
$this->getLogger('conditional_notification')
->warning('Problem updating conditional notification log: @message. Debug Info: @debug.', [
'@message' => $message,
'@debug' => $debug
]);
}
}
......@@ -296,10 +314,15 @@ final class NotificationFactory {
// Only Create log if all conditions met
if ($data['time_offset_enabled'] && $data['entity_date_offset']) {
\Drupal::logger('debug')->warning('DATA<pre><code>' . print_r($data, TRUE) . '</code></pre>');
$this->addToLogQueue($data);
}
else {
$debug = json_encode($data);
$this->getLogger('conditional_notification')
->warning('Problem creating log. Debug Info: @debug.', [
'@debug' => $debug
]);
}
}
}
}
......
......@@ -109,13 +109,6 @@ final class NotificationLogQueue extends QueueWorkerBase implements ContainerFac
// Get the day as string
$entity_date_string_day = $data['entity_date_string_day'];
if ($entity_id == 283) {
\Drupal::logger('debug')->warning('DATA on queue process!! <pre><code>' . print_r($data, TRUE) . '</code></pre>');
}
//\Drupal::logger('debug')->warning('DATA on queue process!! <pre><code>' . print_r($data, TRUE) . '</code></pre>');
if ($this->checkIfRecordsAlreadyExists($data)) {
// Update record
......@@ -137,16 +130,14 @@ final class NotificationLogQueue extends QueueWorkerBase implements ContainerFac
'entity_date_string_day' => $entity_date_string_day,
'entity_date_string_hour' => $entity_date_string_hour,
'processed' => 0,
])->save();
])->save();
}
catch (\Exception $exception) {
$message = $exception->getMessage();
$this->getLogger('conditional_notification')->warning('Problem writing conditional notification log with field: @field',['@field' => $notification_id]);
$this->getLogger('conditional_notification')->warning('Problem writing conditional notification log with field: @field',['@field' => $entity_id]);
$this->getLogger('conditional_notification')->warning('Problem writing conditional notification log with field: @field',['@field' => $entity_date_field_timestamp]);
$this->getLogger('conditional_notification')->warning('Problem writing conditional notification log with field entity date offset: @field',['@field' => $entity_date_offset]);
$this->getLogger('conditional_notification')->warning('Problem writing conditional notification log: @message',['@message' => $message]);
}
}
......
......@@ -124,7 +124,11 @@ final class NotificationQueue extends QueueWorkerBase implements ContainerFactor
}
}
else {
$this->getLogger('conditional_notification')->warning('No recipients found. Check the following plugin: ' . $context);
$debug = json_encode($data);
$this->getLogger('conditional_notification')
->warning('No recipients found. Check the following plugin: @context. Debug info: @debug', [
'@context' => $context, '@debug' => $debug
]);
}
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment