| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
function dblog_help($path, $arg) {
|
| 19 |
|
| 20 |
case 'admin/help#dblog':
|
| 21 |
$output = '<p>' . t('The dblog module monitors your system, capturing system events in a log to be reviewed by an authorized individual at a later time. This is useful for site administrators who want a quick overview of activities on their site. The logs also record the sequence of events, so it can be useful for debugging site errors.') . '</p>';
|
| 22 |
$output .= '<p>' . t('The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the dblog report on a regular basis to ensure their site is working properly.') . '</p>';
|
| 23 |
$output .= '<p>' . t('For more information, see the online handbook entry for <a href="@dblog">Dblog module</a>.', array('@dblog' => 'http://drupal.org/handbook/modules/dblog/')) . '</p>';
|
| 24 |
return $output;
|
| 25 |
case 'admin/reports/dblog':
|
| 26 |
return '<p>' . t('The dblog module monitors your website, capturing system events in a log to be reviewed by an authorized individual at a later time. The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the dblog report on a regular basis as it is often the only way to tell what is going on.') . '</p>';
|
| 27 |
}
|
| 28 |
}
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
function dblog_theme() {
|
| 34 |
|
| 35 |
|
| 36 |
'arguments' => array('form' => NULL),
|
| 37 |
),
|
| 38 |
);
|
| 39 |
}
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
function dblog_menu() {
|
| 45 |
$items['admin/reports/dblog'] = array(
|
| 46 |
'title' => 'Recent log entries',
|
| 47 |
'description' => 'View events that have recently been logged.',
|
| 48 |
'page callback' => 'dblog_overview',
|
| 49 |
'access arguments' => array('access site reports'),
|
| 50 |
'weight' => -1,
|
| 51 |
|
| 52 |
$items['admin/reports/page-not-found'] = array(
|
| 53 |
'title' => "Top 'page not found' errors",
|
| 54 |
'description' => "View 'page not found' errors (404s).",
|
| 55 |
'page callback' => 'dblog_top',
|
| 56 |
'page arguments' => array('page not found'),
|
| 57 |
'access arguments' => array('access site reports'),
|
| 58 |
|
| 59 |
$items['admin/reports/access-denied'] = array(
|
| 60 |
'title' => "Top 'access denied' errors",
|
| 61 |
'description' => "View 'access denied' errors (403s).",
|
| 62 |
'page callback' => 'dblog_top',
|
| 63 |
'page arguments' => array('access denied'),
|
| 64 |
'access arguments' => array('access site reports'),
|
| 65 |
|
| 66 |
$items['admin/reports/event/%'] = array(
|
| 67 |
'title' => 'Details',
|
| 68 |
'page callback' => 'dblog_event',
|
| 69 |
'page arguments' => array(3),
|
| 70 |
'access arguments' => array('access site reports'),
|
| 71 |
'type' => MENU_CALLBACK,
|
| 72 |
|
| 73 |
return $items;
|
| 74 |
}
|
| 75 |
|
| 76 |
function dblog_init() {
|
| 77 |
if (arg(0) == 'admin' && arg(1) == 'reports') {
|
| 78 |
|
| 79 |
drupal_add_css(drupal_get_path('module', 'dblog') . '/dblog.css', array('preprocess' => FALSE));
|
| 80 |
}
|
| 81 |
}
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
function dblog_cron() {
|
| 91 |
|
| 92 |
$max = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
|
| 93 |
db_delete('watchdog')
|
| 94 |
->condition('wid', $max - variable_get('dblog_row_limit', 1000), '<=')
|
| 95 |
->execute();
|
| 96 |
}
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
function dblog_user_cancel($edit, $account, $method) {
|
| 102 |
|
| 103 |
case 'user_cancel_reassign':
|
| 104 |
db_update('watchdog')
|
| 105 |
->fields(array('uid' => 0))
|
| 106 |
->condition('uid', $account->uid)
|
| 107 |
->execute();
|
| 108 |
break;
|
| 109 |
|
| 110 |
case 'user_cancel_delete':
|
| 111 |
db_delete('watchdog')
|
| 112 |
->condition('uid', $account->uid)
|
| 113 |
->execute();
|
| 114 |
break;
|
| 115 |
}
|
| 116 |
}
|
| 117 |
|
| 118 |
function _dblog_get_message_types() {
|
| 119 |
$types = array();
|
| 120 |
|
| 121 |
$result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
|
| 122 |
foreach ($result as $object) {
|
| 123 |
$types[] = $object->type;
|
| 124 |
}
|
| 125 |
|
| 126 |
return $types;
|
| 127 |
}
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
function dblog_watchdog(array $log_entry) {
|
| 135 |
Database::getConnection('default', 'default')->insert('watchdog')
|
| 136 |
->fields(array(
|
| 137 |
'uid' => $log_entry['user']->uid,
|
| 138 |
'type' => substr($log_entry['type'], 0, 64),
|
| 139 |
'message' => $log_entry['message'],
|
| 140 |
'variables' => serialize($log_entry['variables']),
|
| 141 |
'severity' => $log_entry['severity'],
|
| 142 |
'link' => substr($log_entry['link'], 0, 255),
|
| 143 |
'location' => $log_entry['request_uri'],
|
| 144 |
'referer' => $log_entry['referer'],
|
| 145 |
'hostname' => substr($log_entry['ip'], 0, 128),
|
| 146 |
'timestamp' => $log_entry['timestamp'],
|
| 147 |
))
|
| 148 |
->execute();
|
| 149 |
}
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
function theme_dblog_filters($form) {
|
| 157 |
$output = '';
|
| 158 |
foreach (element_children($form['status']) as $key) {
|
| 159 |
$output .= drupal_render($form['status'][$key]);
|
| 160 |
}
|
| 161 |
$output .= '<div id="dblog-admin-buttons">' . drupal_render($form['buttons']) . '</div>';
|
| 162 |
return $output;
|
| 163 |
}
|
| 164 |
|