Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add comments to OpenCart Error log?

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?

like image 346
Jaime Dolor jr. Avatar asked Oct 24 '25 04:10

Jaime Dolor jr.


1 Answers

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/

like image 116
focus.style Avatar answered Oct 26 '25 18:10

focus.style