Zen Cart Logo
Forums / Addon Admin Tools / Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Views: 22,767

Results 1 to 20 of 95
22 Dec 2012, 7:15 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

There have been many times that I've taken a look in one of my Zen Cart's /logs (or /cache for Zen Cart v1.5.0) directories and found some debug log files that I wasn't previously aware of. This plugin allows an admin user to view (and selectively delete) any files with names that match:

myDEBUG-*.log
AIM_Debug_*.log
SIM_Debug_*.log
FirstData_Debug_*.log
Linkpoint_Debug_*.log
Paypal*.log
paypal*.log
ipn_*.log
zcInstall*.log
notify*.log

The plugin searches only in these directories for the matching log-files:

/cache
/logs
/includes/modules/payment/paypal/logs

Once installed, the plugin can be accessed by a signed-in and authorized admin user by selecting Tools->Display Log Files.

Note: Due to the potentially sensitive nature of the information contained in some of the log files, I suggest that you run your admin in SSL mode if you use this plugin.

Due the the number of files that can accumulate, only the most recent 20 are displayed by default. If you want to display more files at a time, edit the file /YOUR_ADMIN/display_logs.php and change line 23:

define('MAX_LOG_FILES_TO_VIEW', 20);

The tool allows the logged-in (and authorized) admin user to:

Sort the log files, either ascendingly or descendingly, by last-modified/creation date.
Select (via checkbox) and then delete only the log files selected.
Delete all log files currently being viewed.
View the contents of an individual log file.

It's been tested on Zen Cart v1.5.0 and v1.5.1 and will be submitted to the Plugins area for review today.

22 Dec 2012, 7:23 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

When approved, the plugin will be available here: http://www.zen-cart.com/downloads.php?do=file&id=1583

22 Dec 2012, 7:58 PM
#3
jlizotte avatar

jlizotte

New Zenner

Join Date:
Feb 2012
Location:
Ohio, USA
Posts:
58
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

This will be a nice addition. Thank you :)

22 Dec 2012, 8:33 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

It's now available in the plugins ... holy crow, that was fast!

23 Dec 2012, 6:41 AM
#5
rizla avatar

rizla

Zen Follower

Join Date:
Sep 2010
Posts:
449
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Will it work for 1.3.9h

23 Dec 2012, 7:51 AM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Rizla:

Will it work for 1.3.9h
Sorry, it currently works on v1.5.0 and v1.5.1 only.

23 Dec 2012, 8:14 AM
#7
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Now that's doing it properly! Where do you find the time!

I also had a desire to know about debug logs when I caused them, so I made up something very basic to just push the logs in my face above the header...which may suit some people:
http://www.zen-cart.com/showthread.php?181798-Show-Debug-Files-Automatically

23 Dec 2012, 9:13 AM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Thanks for the compliment, Steve. I guess I just got tired of FTPing debug log files, so it's actually going to be a time-saver for me!

23 Dec 2012, 1:40 PM
#9
jlizotte avatar

jlizotte

New Zenner

Join Date:
Feb 2012
Location:
Ohio, USA
Posts:
58
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

Ok. I renamed my admin and uploaded the files. Getting a 500 server error. I do have a logs and cache directory, but I'm getting this error in my debugs:

PHP Warning: dir(DIR_FS_LOGS) [<a href='function.dir'>function.dir</a>]: failed to open dir: No such file or directory in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 41
[23-Dec-2012 08:34:23] PHP Fatal error: Call to a member function read() on a non-object in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 42

Any idea what the problem might be? The error reads like it is looking for function.dir.

(Running this on 1.5.1) White screen of death when I choose Display Logs from the admin menu, then it generates the debug in my cache folder.

Thanks.

23 Dec 2012, 2:35 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

jlizotte:

Ok. I renamed my admin and uploaded the files. Getting a 500 server error. I do have a logs and cache directory, but I'm getting this error in my debugs:

PHP Warning: dir(DIR_FS_LOGS) [<a href='function.dir'>function.dir</a>]: failed to open dir: No such file or directory in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 41
[23-Dec-2012 08:34:23] PHP Fatal error: Call to a member function read() on a non-object in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 42

Any idea what the problem might be? The error reads like it is looking for function.dir.

(Running this on 1.5.1) White screen of death when I choose Display Logs from the admin menu, then it generates the debug in my cache folder.

Thanks.
The error message indicates that the constant DIR_FS_LOGS is not defined so that the PHP dir function is choking. Running on v1.5.1, you ***should *** have the DIR_FS_LOGS constant defined in both /YOUR_ADMIN/includes/configure.php and /includes/configure.php. I'm guessing that this was an upgrade to v1.5.1 for your site.

That said, the plugin shouldn't be giving you the white-screen-of-death. I don't seem to have an issue with or without the DIR_FS_LOGS constant on v1.5.1 because the Zen Cart init handlers 'fix' it. It's another story on v1.5.0, however, where I'm seeing what you're seeing.

Make the changes highlighted in red to /YOUR_ADMIN/display_logs.php, starting at line 39:

     foreach(array(DIR_FS_LOGS, DIR_FS_SQL_CACHE, DIR_FS_CATALOG . '/includes/modules/payment/paypal/logs') as $logFolder) {
      $logFolder = rtrim($logFolder, '/'); 
      $dir = @dir($logFolder);
      if ($dir != NULL) {
        while ($file = $dir->read()) {
          if ( ($file != '.') && ($file != '..') && substr($file, 0, 1) != '.') {
            if (preg_match('/^(myDEBUG-|AIM_Debug_|SIM_Debug_|FirstData_Debug_|Linkpoint_Debug_|Paypal|paypal|ipn_|zcInstall).*\.log$/', $file)) {
              $hash = sha1 ($logFolder . '/' . $file);
              $logFiles[$hash] = array ( 'name'  => $logFolder . '/' . $file,
                                         'mtime' => filemtime($logFolder . '/' . $file)
                                       );
            }
          }
        }
      }         

I'll hold off on resubmission to the Plugins for a bit, just in case ...

23 Dec 2012, 2:59 PM
#11
jlizotte avatar

jlizotte

New Zenner

Join Date:
Feb 2012
Location:
Ohio, USA
Posts:
58
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

You're right, it was an upgrade. Making the changes above, I now get:

Parse error: syntax error, unexpected $end in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 309

You were also right, the defines for my logs directory was missing in the configure files. I added:

define('DIR_FS_LOGS', DIR_FS_LOGS . 'logs/');

to both configures, but I'm still getting the error from line 309. For the heck of it, I went back to your orignal code on display_logs.php since I added the define statements, and I'm back to getting the 500 error.

Thank you for trying to help.

23 Dec 2012, 3:24 PM
#12
limitless avatar

limitless

Inactive

Join Date:
Jan 2012
Posts:
496
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

lat9:

The error message indicates that the constant DIR_FS_LOGS is not defined so that the PHP dir function is choking. Running on v1.5.1, you ***should *** have the DIR_FS_LOGS constant defined in both /YOUR_ADMIN/includes/configure.php and /includes/configure.php. I'm guessing that this was an upgrade to v1.5.1 for your site.

That said, the plugin shouldn't be giving you the white-screen-of-death. I don't seem to have an issue with or without the DIR_FS_LOGS constant on v1.5.1 because the Zen Cart init handlers 'fix' it. It's another story on v1.5.0, however, where I'm seeing what you're seeing.

Make the changes highlighted in red to /YOUR_ADMIN/display_logs.php, starting at line 39:

 foreach(array(DIR_FS_LOGS, DIR_FS_SQL_CACHE, DIR_FS_CATALOG . '/includes/modules/payment/paypal/logs') as $logFolder) {
  $logFolder = rtrim($logFolder, '/'); 
  $dir = @dir($logFolder);
  if ($dir != NULL) {
    while ($file = $dir->read()) {
      if ( ($file != '.') && ($file != '..') && substr($file, 0, 1) != '.') {
        if (preg_match('/^(myDEBUG-|AIM_Debug_|SIM_Debug_|FirstData_Debug_|Linkpoint_Debug_|Paypal|paypal|ipn_|zcInstall).*\.log$/', $file)) {
          $hash = sha1 ($logFolder . '/' . $file);
          $logFiles[$hash] = array ( 'name'  => $logFolder . '/' . $file,
                                     'mtime' => filemtime($logFolder . '/' . $file)
                                   );
        }
      }
    }
  }         
> I'll hold off on resubmission to the Plugins for a bit, just in case ...


These changes fixed the 500 error on 1.50.

Thanks for this addition!
23 Dec 2012, 3:25 PM
#13
jlizotte avatar

jlizotte

New Zenner

Join Date:
Feb 2012
Location:
Ohio, USA
Posts:
58
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

jlizotte:

You're right, it was an upgrade. Making the changes above, I now get:

Parse error: syntax error, unexpected $end in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 309

It's actually the last line of your file: <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

(I had commented out the changes I made above.)

Again, thanks for your help. I can muddle through PHP with direction, but only know enough to figure out the most basic parts of it.

23 Dec 2012, 3:38 PM
#14
jlizotte avatar

jlizotte

New Zenner

Join Date:
Feb 2012
Location:
Ohio, USA
Posts:
58
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

OK. I got this working. I had to add a fifth "}" at the end of your modification above. It's working great now!

Thank you, lat9, for your help, and for a great contribution. Happy holidays!

23 Dec 2012, 5:06 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

jlizotte:

You're right, it was an upgrade. Making the changes above, I now get:

Parse error: syntax error, unexpected $end in /home/xxxxxx/ohwowthatscool.com/myadmin/display_logs.php on line 309

You were also right, the defines for my logs directory was missing in the configure files. I added:

define('DIR_FS_LOGS', DIR_FS_LOGS . 'logs/');

to both configures, but I'm still getting the error from line 309. For the heck of it, I went back to your orignal code on display_logs.php since I added the define statements, and I'm back to getting the 500 error.

Thank you for trying to help.

Should be:
define('DIR_FS_LOGS', DIR_FS_CATALOG . 'logs/');

23 Dec 2012, 5:12 PM
#16
jlizotte avatar

jlizotte

New Zenner

Join Date:
Feb 2012
Location:
Ohio, USA
Posts:
58
Plugin Contributions:
0

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

DrByte:

Should be:
define('DIR_FS_LOGS', DIR_FS_CATALOG . 'logs/');

Oops. Many thanks, Sir!

23 Dec 2012, 6:59 PM
#17
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

DrByte:

Should be:
define('DIR_FS_LOGS', DIR_FS_CATALOG . 'logs/');
Er, my v1.5.1 copy of configure.php has a comment that reads:

 //the following path is a COMPLETE path to the /logs/ folder  eg: /var/www/vhost/accountname/public_html/store/logs ... and no trailing slash
23 Dec 2012, 7:27 PM
#18
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

The updated version is available here, as v1.0.0a for the next week or so; then I'll resubmit to the Plugins area. Just click the "Download Now" button.

5 Jan 2013, 12:48 PM
#19
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

I've repackaged v1.0.0a as v1.0.1 and submitted the update to the Zen Cart Plugins area ...

29 Mar 2013, 8:30 AM
#20
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Display Log Files [Support Thread] (v1.5.1-to-v1.5.6)

I have added the debug-file file-size to the listing of the debug file. I find this very handy in finding potentially the same errors. If anyone else is interested, I will upload this "upgraded version"