Someone (hello Nigel) just mentioned they would like
Occasionally while fiddling about with all this code I don't quite understand, I don't cause a white screen of death immediately, but later I find that there are debug files in the cache.For a widget, I would specifically like one that tells me
1) How many debugfiles are in /cache
2) Displays the contents of the latest debug file
I'd prefer to know this at the time so this is a bit of code I did to flag up in the admin when there are debug.log files generated in the cache.
I put it at the top of admin/includes/header.php to use the standard error reporting function
so find
and put this code before it// display alerts/error messages, if any
if ($messageStack->size > 0) {
echo $messageStack->output();
}
Test it by creating a whatever.log text file in the cache directory.// check for debug logs
$path = str_replace(DIR_FS_CATALOG, '../', DIR_FS_SQL_CACHE).'/';
if (count(glob($path . '*.*')) > 1) {//only htaccess and index.php are in directory normally
$directory = opendir($path);
while($item = readdir($directory)){
if (strpos($item, '.log',1)){
$messageStack->add('Debug log file exists: '.DIR_FS_SQL_CACHE.'/'.$item);
}
}
}
The admin should display the error bar at the top of the admin pages with this info.
Improvements to this code are most welcome, if not essential (I wouldn't know).
regards
Steve
Bookmarks