Show Debug Files Automatically
Someone (hello Nigel) just mentioned they would like
Quote:
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
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.
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
Quote:
// display alerts/error messages, if any
if ($messageStack->size > 0) {
echo $messageStack->output();
}
and put this code before it
Quote:
// 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);
}
}
}
Test it by creating a whatever.log text file in the cache directory.
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
Re: Show Debug Files Automatically
Cheers Steve, I have been looking at writing something similar, but that suits my needs perfectly
Re: Show Debug Files Automatically
Have tried but can't seem to get this to work with 1.5.1
Any hints or solutions welcome please.
Re: Show Debug Files Automatically
Debug log files now go in the /logs/ folder instead of the /cache/ folder.
Re: Show Debug Files Automatically
Quote:
Originally Posted by
gjh42
Debug log files now go in the /logs/ folder instead of the /cache/ folder.
Thank you Glenn but where would I edit the above to point to the correct path, logs rather than cache?
Re: Show Debug Files Automatically
Quote:
Have tried but can't seem to get this to work with 1.5.1
This is what I have, using 1.51.
PHP Code:
// steve check for and display debug logs
$path = str_replace(DIR_FS_CATALOG,'../',DIR_FS_LOGS).'/';
$matches = glob($path ."myDEBUG*.*");
if (is_array($matches)) {
foreach ($matches as $filename) {
$messageStack->add('Debug log file exists: '.str_replace($path,DIR_FS_LOGS.'/',$filename),'warning');
}
}
Re: Show Debug Files Automatically
Quote:
Originally Posted by
torvista
This is what I have, using 1.51.
PHP Code:
// steve check for and display debug logs
$path = str_replace(DIR_FS_CATALOG,'../',DIR_FS_LOGS).'/';
$matches = glob($path ."myDEBUG*.*");
if (is_array($matches)) {
foreach ($matches as $filename) {
$messageStack->add('Debug log file exists: '.str_replace($path,DIR_FS_LOGS.'/',$filename),'warning');
}
}
Thank you I really appreciate that, I'll give that a go later.
Re: Show Debug Files Automatically
Nice one, Steve! Thanks for sharing.
Re: Show Debug Files Automatically
Yes thankyou again, works a treat and I think it compliments Lat9's handy mod too, thank you both.
Re: Show Debug Files Automatically
I just noticed, looking through the Zen Cart github repository, that this feature is slated for inclusion in the Zen Cart v1.6.0 admin! :clap: