function _apdqc_dblog_watchdog in Asynchronous Prefetch Database Query Cache 7
Implements hook_watchdog().
Note: Some values may be truncated to meet database column size restrictions.
File
- ./
apdqc.module, line 298 - Asynchronous Prefetch Database Query Cache module.
Code
function _apdqc_dblog_watchdog(array $log_entry) {
// Pass through if apdqc_dblog_watchdog is disabled.
// Or if apdqc_run_prefetch_array is not defined; apdqc.cache.inc not loaded.
if (!variable_get('apdqc_dblog_watchdog', APDQC_DBLOG_WATCHDOG) || !function_exists('apdqc_run_prefetch_array') || !function_exists('apdqc_escape_string')) {
if (function_exists('dblog_watchdog')) {
return dblog_watchdog($log_entry);
}
return;
}
// Escape data.
$field_data = array(
'uid' => apdqc_escape_string($log_entry['uid']),
'type' => apdqc_escape_string(substr($log_entry['type'], 0, 64)),
'message' => apdqc_escape_string($log_entry['message']),
'variables' => apdqc_escape_string(serialize($log_entry['variables'])),
'severity' => apdqc_escape_string($log_entry['severity']),
'link' => apdqc_escape_string(substr($log_entry['link'], 0, 255)),
'location' => apdqc_escape_string($log_entry['request_uri']),
'referer' => apdqc_escape_string($log_entry['referer']),
'hostname' => apdqc_escape_string(substr($log_entry['ip'], 0, 128)),
'timestamp' => apdqc_escape_string($log_entry['timestamp']),
);
// Get table name.
$table = Database::getConnection()
->prefixTables("{" . db_escape_table('watchdog') . "}");
// Build query.
$query = "\n INSERT INTO {$table} (\n uid,\n type,\n message,\n variables,\n severity,\n link,\n location,\n referer,\n hostname,\n timestamp\n )\n VALUES (\n '{$field_data['uid']}',\n '{$field_data['type']}',\n '{$field_data['message']}',\n '{$field_data['variables']}',\n '{$field_data['severity']}',\n '{$field_data['link']}',\n '{$field_data['location']}',\n '{$field_data['referer']}',\n '{$field_data['hostname']}',\n '{$field_data['timestamp']}'\n )\n ";
// Insert info into watchdog table in a non blocking manner.
apdqc_query(array(
$table,
), array(
microtime(TRUE),
), $query, array(
'async' => TRUE,
));
}