function dblog_watchdog in Drupal 7
Same name and namespace in other branches
- 6 modules/dblog/dblog.module \dblog_watchdog()
Implements hook_watchdog().
Note: Some values may be truncated to meet database column size restrictions.
4 calls to dblog_watchdog()
- DBLogTestCase::generateLogEntries in modules/
dblog/ dblog.test - Generates a number of random database log events.
- DBLogTestCase::testDBLogAddAndClear in modules/
dblog/ dblog.test - Tests the addition and clearing of log events through the admin interface.
- DBLogTestCase::testDBLogException in modules/
dblog/ dblog.test - Verifies that exceptions are caught in dblog_watchdog().
- DBLogTestCase::testLogMessageSanitized in modules/
dblog/ dblog.test - Make sure HTML tags are filtered out in the log detail page.
File
- modules/
dblog/ dblog.module, line 146 - System monitoring and logging for administrators.
Code
function dblog_watchdog(array $log_entry) {
if (!function_exists('drupal_substr')) {
require_once DRUPAL_ROOT . '/includes/unicode.inc';
}
try {
Database::getConnection('default', 'default')
->insert('watchdog')
->fields(array(
'uid' => $log_entry['uid'],
'type' => drupal_substr($log_entry['type'], 0, 64),
'message' => $log_entry['message'],
'variables' => serialize($log_entry['variables']),
'severity' => $log_entry['severity'],
'link' => drupal_substr($log_entry['link'], 0, 255),
'location' => $log_entry['request_uri'],
'referer' => $log_entry['referer'],
'hostname' => drupal_substr($log_entry['ip'], 0, 128),
'timestamp' => $log_entry['timestamp'],
))
->execute();
} catch (Exception $e) {
// Exception is ignored so that watchdog does not break pages during the
// installation process or is not able to create the watchdog table during
// installation.
}
}