In Laravel, I can use the log() command to add comments to the log file (which helps me debug), something like this:
$var = 'this is a variable';
//some other code goes here
log::('Is $var a null? Here is the value '.$var);
I can then check in the log file.
How do I do this in OpenCart?
In OpenCart 2 and 3 there is log library in /system/library/log.php
This library is accessible from almost everywhere (from any model and controller). You can easily use it like:
$var = 'this is a variable';
//some other code goes here
$this->log->write('Is $var a null? Here is the value '.$var);
Log files you will find in /system/storage/logs/error.log
Other way
$var = 'this is a variable';
//some other code goes here
$log = new Log('LOG_NAME.log');
$log->write('Is $var a null? Here is the value '.$var);
You will find your log file in /system/storage/logs/
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