function _drd_server_export_debug_log in Drupal Remote Dashboard Server 7.2
Same name and namespace in other branches
- 6.2 drd_server.admin.inc \_drd_server_export_debug_log()
Exports all current debug log entries from watchdog to an HTML file.
1 call to _drd_server_export_debug_log()
- drd_server_settings_submit in ./
drd_server.admin.inc - Submit handler for the settings form.
File
- ./
drd_server.admin.inc, line 409 - Provides functionality for configuring drd_server and to return blocks for the admin module.
Code
function _drd_server_export_debug_log() {
if (!module_exists('dblog')) {
drupal_set_message('Module dblog not enabled, nothing to export.', 'error');
return;
}
$entries = db_select('watchdog', 'w')
->fields('w', array(
'message',
'variables',
'timestamp',
))
->condition('w.type', 'DRD Server')
->orderBy('w.wid')
->execute()
->fetchAll();
if (empty($entries)) {
drupal_set_message('No debug entries available.', 'warning');
return;
}
$filename = 'drd_server_debug_' . format_date(REQUEST_TIME, 'custom', 'Ymd_hi') . '.html';
$n = 0;
$html = '<html><body><h1>DRD Server Debug Log</h1>';
foreach ($entries as $entry) {
$n++;
$html .= '<p><span>' . $entry->timestamp . '</span> ' . t($entry->message, unserialize($entry->variables)) . '</p>';
}
$html .= '</body></html>';
file_put_contents(file_directory_temp() . '/' . $filename, $html);
drupal_set_message(t('DRD Server debug exported with !n records. !link', array(
'!n' => $n,
'!link' => l('Download', 'system/temporary/' . $filename),
)));
}