Is some solution in prestashop for tracking hooks call? Especially actions hooks I need to check where hooks is call and what hooks doing. It is hard to find functions for hooks. They can be everywhere.
All hook executions are done by funcion exec from Hook class. You can add a debug trace at the beginning of this function:
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true,
$use_push = false, $id_shop = null)
{
$logger = new FileLogger(0);
$logger->setFilename(_PS_ROOT_DIR_.'/log/debug.log');
$e = new Exception;
$logger->logDebug('Hook '.$hook_name.' called from:');
$logger->logDebug($e->getTraceAsString());
....
This will create a debug log at /log/debug.log and will display the information about who call this hook.
Even better if you override this function to do so ;)
You can also debug all the INSERT in your DB.
Add this code
protected function q($sql, $use_cache = true)
{
$logger = new FileLogger(0);
$logger->setFilename(_PS_ROOT_DIR_.'/log/sql.log');
$e = new Exception;
$logger->logDebug('SQL '.$sql.' executed from:');
$logger->logDebug($e->getTraceAsString());
...
in q function from Db class (/classes/db/Db.php).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With