Mercurial > hg > isophonics-drupal-site
comparison core/modules/dblog/dblog.module @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
7 * The Database Logging module monitors your site and keeps a list of recorded | 7 * The Database Logging module monitors your site and keeps a list of recorded |
8 * events containing usage and performance data, errors, warnings, and similar | 8 * events containing usage and performance data, errors, warnings, and similar |
9 * operational information. | 9 * operational information. |
10 */ | 10 */ |
11 | 11 |
12 use Drupal\Core\Url; | |
12 use Drupal\Core\Form\FormStateInterface; | 13 use Drupal\Core\Form\FormStateInterface; |
13 use Drupal\Core\Routing\RouteMatchInterface; | 14 use Drupal\Core\Routing\RouteMatchInterface; |
14 use Drupal\Core\StringTranslation\TranslatableMarkup; | 15 use Drupal\Core\StringTranslation\TranslatableMarkup; |
15 use Drupal\views\ViewEntityInterface; | 16 use Drupal\views\ViewEntityInterface; |
16 use Drupal\views\ViewExecutable; | 17 use Drupal\views\ViewExecutable; |
25 $output .= '<h3>' . t('About') . '</h3>'; | 26 $output .= '<h3>' . t('About') . '</h3>'; |
26 $output .= '<p>' . t('The Database Logging module logs system events in the Drupal database. For more information, see the <a href=":dblog">online documentation for the Database Logging module</a>.', [':dblog' => 'https://www.drupal.org/documentation/modules/dblog']) . '</p>'; | 27 $output .= '<p>' . t('The Database Logging module logs system events in the Drupal database. For more information, see the <a href=":dblog">online documentation for the Database Logging module</a>.', [':dblog' => 'https://www.drupal.org/documentation/modules/dblog']) . '</p>'; |
27 $output .= '<h3>' . t('Uses') . '</h3>'; | 28 $output .= '<h3>' . t('Uses') . '</h3>'; |
28 $output .= '<dl>'; | 29 $output .= '<dl>'; |
29 $output .= '<dt>' . t('Monitoring your site') . '</dt>'; | 30 $output .= '<dt>' . t('Monitoring your site') . '</dt>'; |
30 $output .= '<dd>' . t('The Database Logging module allows you to view an event log on the <a href=":dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', [':dblog' => \Drupal::url('dblog.overview')]) . '</dd>'; | 31 $output .= '<dd>' . t('The Database Logging module allows you to view an event log on the <a href=":dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', [':dblog' => Url::fromRoute('dblog.overview')->toString()]) . '</dd>'; |
31 $output .= '<dt>' . t('Debugging site problems') . '</dt>'; | 32 $output .= '<dt>' . t('Debugging site problems') . '</dt>'; |
32 $output .= '<dd>' . t('In case of errors or problems with the site, the <a href=":dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', [':dblog' => \Drupal::url('dblog.overview')]) . '</dd>'; | 33 $output .= '<dd>' . t('In case of errors or problems with the site, the <a href=":dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', [':dblog' => Url::fromRoute('dblog.overview')->toString()]) . '</dd>'; |
33 $output .= '</dl>'; | 34 $output .= '</dl>'; |
34 return $output; | 35 return $output; |
35 | 36 |
36 case 'dblog.overview': | 37 case 'dblog.overview': |
37 return '<p>' . t('The Database Logging module logs system events in the Drupal database. Monitor your site or debug site problems on this page.') . '</p>'; | 38 return '<p>' . t('The Database Logging module logs system events in the Drupal database. Monitor your site or debug site problems on this page.') . '</p>'; |
65 | 66 |
66 // For row limit n, get the wid of the nth row in descending wid order. | 67 // For row limit n, get the wid of the nth row in descending wid order. |
67 // Counting the most recent n rows avoids issues with wid number sequences, | 68 // Counting the most recent n rows avoids issues with wid number sequences, |
68 // e.g. auto_increment value > 1 or rows deleted directly from the table. | 69 // e.g. auto_increment value > 1 or rows deleted directly from the table. |
69 if ($row_limit > 0) { | 70 if ($row_limit > 0) { |
70 $min_row = db_select('watchdog', 'w') | 71 $connection = \Drupal::database(); |
72 $min_row = $connection->select('watchdog', 'w') | |
71 ->fields('w', ['wid']) | 73 ->fields('w', ['wid']) |
72 ->orderBy('wid', 'DESC') | 74 ->orderBy('wid', 'DESC') |
73 ->range($row_limit - 1, 1) | 75 ->range($row_limit - 1, 1) |
74 ->execute()->fetchField(); | 76 ->execute()->fetchField(); |
75 | 77 |
76 // Delete all table entries older than the nth row, if nth row was found. | 78 // Delete all table entries older than the nth row, if nth row was found. |
77 if ($min_row) { | 79 if ($min_row) { |
78 db_delete('watchdog') | 80 $connection->delete('watchdog') |
79 ->condition('wid', $min_row, '<') | 81 ->condition('wid', $min_row, '<') |
80 ->execute(); | 82 ->execute(); |
81 } | 83 } |
82 } | 84 } |
83 } | 85 } |
101 $form['dblog_row_limit'] = [ | 103 $form['dblog_row_limit'] = [ |
102 '#type' => 'select', | 104 '#type' => 'select', |
103 '#title' => t('Database log messages to keep'), | 105 '#title' => t('Database log messages to keep'), |
104 '#default_value' => \Drupal::configFactory()->getEditable('dblog.settings')->get('row_limit'), | 106 '#default_value' => \Drupal::configFactory()->getEditable('dblog.settings')->get('row_limit'), |
105 '#options' => [0 => t('All')] + array_combine($row_limits, $row_limits), | 107 '#options' => [0 => t('All')] + array_combine($row_limits, $row_limits), |
106 '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [':cron' => \Drupal::url('system.status')]), | 108 '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [':cron' => Url::fromRoute('system.status')->toString()]), |
107 ]; | 109 ]; |
108 | 110 |
109 $form['#submit'][] = 'dblog_logging_settings_submit'; | 111 $form['#submit'][] = 'dblog_logging_settings_submit'; |
110 } | 112 } |
111 | 113 |