Simple Debug Tool

Simple Debug Tool
Version 1.1.4 (28 Mar 2017)
Bugfix

If you are not actively editing PHP code, this mod is not for you !

New Check the debug log via System > Tools > Debug Log

How frustrating is it when you're trying to develop a mod and you're getting unexpected results. To try and establish where the script is going wrong or falling over can be quite tricky, especially when you can't "echo" valuable information to the screen. I got fed up writing several lines of code in order to capture certain information or write it to a file, so I developed the "Simple Debug Tool'. With one line of code at the appropriate point, I can leave messages, record the value of variables and the content of arrays.

Whether you're trying to debug the controller or model files, the catalog or the admin side of your mod, just a simple line of code puts all the information you're looking for into a log file where you can easily check what's happening.

This simple modification extends the "Log" class and adds 3 new methods:
  • $this->log-debug($output);
  • $this->log->resetDebug();
  • $this->log->displayErrors();


$this->log->debug($output)
This line of code writes $output to a file system/logs/debug.txt. $output can be a string, a variable or an array and can be helpful in debugging a script that is giving unexpected results. Simply add the line at an appropriate point in the script eg.

  • $this->log->debug('I have reached "X" point in the script'); (Adds the string to the log)
  • $this->log->debug($language_id); (Adds the content of the variable $language_id to the log)
  • $this->log->debug($this->request->post['status']); (Adds the content of the POSTed variable 'status' to the log)
  • $this->log->debug($this->request->post); (Adds the content of the complete POST array to the log)
  • $this->log->debug($this->session->data['user_id']); (Adds the content of the session variable 'user_id' to the log)
  • $this->log->debug($query->rows); (Adds the selected database data to the log)


You can use an optional second parameter to provide a "label" for the output eg:
$this->log->debug('The complete POST array', $this->request->post);.

This has the same effect as if you had written two separate lines of code eg:
$this->log->debug('The complete POST array');.
$this->log->debug($this->request->post);.

$this->log->resetDebug()
Simply empties the log file so you don't have to scroll to the end of a long file if you haven't deleted previous entries.

Installation

IMPORTANT. This Extension requires that you have VQMod installed.
If VQMod is not installed you can obtain it free from here : https://github.com/vqmod/vqmod/wiki

Simply extract the files from the archive and copy the vqmod folder to the root folder of your store.




Download
  • Developed by OpenCart Community
  • Documentation Included

Rating

Compatibility
3.0.0.0, 3.0.1.1, 3.0.1.2, 3.0.2.0, 3.1.0.0_b, 2.0.0.0, 2.0.1.0, 2.0.1.1, 2.0.2.0, 2.0.3.1, 2.1.0.1, 2.1.0.2, 2.2.0.0, 1.5.4, 1.5.4.1, 1.5.5.1, 1.5.6, 1.5.6.1, 1.5.6.2, 1.5.6.3, 1.5.6.4, 2.3.0.0, 2.3.0.1, 2.3.0.2

Last Update
18 Oct 2017

Created
6 Feb 2015
971 Downloads
12 Comments
justcurious
justcurious
Member since: 11 Sep 2011

View all extensions Get Support