function raven_test_page_build in Raven: Sentry Integration 7.3
Same name and namespace in other branches
- 7.4 tests/raven_test.module \raven_test_page_build()
- 7.2 tests/raven_test.module \raven_test_page_build()
Implements hook_page_build().
File
- tests/
raven_test.module, line 11 - Raven test module.
Code
function raven_test_page_build(array &$page) {
$client = raven_get_client();
$client
->setSendCallback(function ($data) use (&$page) {
if (!empty($data['logger']) && !empty($data['sentry.interfaces.Message']['formatted'])) {
$page['content']['#attached']['drupal_add_http_header'][] = array(
$data['logger'],
$data['sentry.interfaces.Message']['formatted'],
FALSE,
);
if (strpos($data['logger'], 'X-Watchdog') === 0) {
$last_frame = end($data['stacktrace']['frames']);
$page['content']['#attached']['drupal_add_http_header'][] = array(
$data['logger'] . '-File',
$last_frame['filename'],
FALSE,
);
$page['content']['#attached']['drupal_add_http_header'][] = array(
$data['logger'] . '-Function',
$last_frame['function'],
FALSE,
);
if (isset($data['request']['cookies'])) {
$page['content']['#attached']['drupal_add_http_header'][] = array(
$data['logger'] . '-Cookies',
drupal_json_encode($data['request']['cookies']),
FALSE,
);
}
}
}
if (!empty($data['exception']['values'][0]['value'])) {
if (preg_match('/Allowed memory size of ([0-9]+) bytes exhausted/', $data['exception']['values'][0]['value'], $matches)) {
echo $matches[1];
}
}
return FALSE;
});
watchdog('X-Logged', 'Logged');
watchdog('X-Not-Logged', 'Not logged');
watchdog('X-Logged', 'Logged');
watchdog('X-Watchdog', 'This is a watchdog message.');
try {
raven_test_throw_exception();
} catch (Exception $e) {
watchdog_exception('X-Watchdog-Exception', $e);
}
if (!empty($_GET['memory_limit'])) {
ini_set('memory_limit', (int) $_GET['memory_limit']);
while (TRUE) {
$page[] = 1;
}
}
setcookie('ravenCookie', 'asd');
}