在 Laravel 中,我可以使用 log()
命令向日志文件添加注释(这有助于我调试),如下所示:
$var = 'this is a variable';
//some other code goes here
log::('Is $var a null? Here is the value '.$var);
然后我可以检查日志文件。
我如何在 OpenCart 中执行此操作?
最佳答案
在 OpenCart 2 和 3 中,/system/library/log.php 中有日志库
这个库几乎可以从任何地方访问(从任何模型和 Controller )。您可以像这样轻松地使用它:
$var = 'this is a variable';
//some other code goes here
$this->log->write('Is $var a null? Here is the value '.$var);
您将在 /system/storage/logs/error.log 中找到日志文件
其他方式
$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);
您将在/system/storage/logs/ 中找到您的日志文件
关于php - 如何向 OpenCart 错误日志添加评论?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63150413/