function new_relic_rpm_watchdog in New Relic 7
Implements hook_watchdog().
File
- ./
new_relic_rpm.module, line 247 - Drupal module implementing New Relic.
Code
function new_relic_rpm_watchdog(array $log_entry) {
global $base_url;
// Don't do anything if the new relic extension is not available.
if (!function_exists('newrelic_notice_error')) {
return;
}
// Skip if already logged.
if (!empty($log_entry['variables']['new_relic_already_logged'])) {
return;
}
// Check if the severity is supposed to be logged.
if (!in_array($log_entry['severity'], variable_get('new_relic_rpm_watchdog_severities', array()), true)) {
return;
}
// Avoid marking when cron completed normally as an Notice Error
if ($log_entry['type'] === 'cron' && $log_entry['severity'] === WATCHDOG_NOTICE && $log_entry['message'] === 'Cron run completed.') {
return;
}
$severity_list = watchdog_severity_levels();
$message = '@message | Severity: (@severity) @severity_desc | Type: @type | Request URI: @request_uri | Referrer URI: @referer_uri | User: (@uid) @name | IP Address: @ip';
$message = strtr($message, array(
'@severity' => $log_entry['severity'],
'@severity_desc' => $severity_list[$log_entry['severity']],
'@type' => $log_entry['type'],
'@ip' => $log_entry['ip'],
'@request_uri' => $log_entry['request_uri'],
'@referer_uri' => $log_entry['referer'],
'@uid' => $log_entry['uid'],
'@name' => format_username($log_entry['user']),
'@message' => strip_tags(strtr($log_entry['message'], is_array($log_entry['variables']) ? $log_entry['variables'] : array())),
));
newrelic_notice_error($message);
}