Watchdog Messages
Component ID
2160979
Component name
Watchdog Messages
Component type
module
Maintenance status
Development status
Component security advisory coverage
covered
Downloads
456
Component created
Component changed
Component body
This module displays watchdog entries as Drupal messages on the page. Useful for debugging, or for 3rd party modules, that wishes to capture watchdog entries.
Usage:
<?php
// Display all watchdog log entries generated by function call as messages.
$capture = watchdog_messages_capture();
my_function_that_may_generate_watchdog_messages($var1, $var2);
// Explicitly end capturing. Otherwise the capturing will
// persistent until the end of scope.
unset($capture);
?>
<?php
// Only display watchdog log entries of type "cron" as messages.
$capture = watchdog_messages_capture(array('filter' => array('cron')));
my_function_that_may_generate_watchdog_messages($var1, $var2);
// Explicitly end capturing. Otherwise the capturing will
// persistent until the end of scope.
unset($capture);
?>
<?php
// Capture all watchdog log entries generated by function call.
$capture = watchdog_messages_capture(array('render' => FALSE));
my_function_that_may_generate_watchdog_messages($var1, $var2);
$captured_so_far = $capture->entries;
my_function_that_may_generate_watchdog_messages($var1, $var2);
$captured = $capture->entries;
// Explicitly end capturing. Otherwise the capturing will
// persistent until the end of scope.
unset($capture);
?>
<?php
// Display all watchdog log entries generated by function call as messages.
// Use another function than drupal_set_message().
$capture = watchdog_messages_capture(array(
'render callback' =>'my_own_render_function'
));
my_function_that_may_generate_watchdog_messages($var1, $var2);
// Explicitly end capturing. Otherwise the capturing will
// persistent until the end of scope.
unset($capture);
?>
<?php
// Only display watchdog log entries of type "cron" as messages.
// Use another function than drupal_set_message().
$capture = watchdog_messages_capture(array(
'render callback' =>'my_own_render_function',
'filter' => array('cron'),
));
my_function_that_may_generate_watchdog_messages($var1, $var2);
// Explicitly end capturing. Otherwise the capturing will
// persistent until the end of scope.
unset($capture);
?>
