php - 如何向 OpenCart 错误日志添加评论?

标签 php opencart opencart2.x

在 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/

相关文章:

php - 如何获取多维数组的所有路径

php - 过滤文件中的查询结果

opencart - 默认样式表始终加载 [OpenCart 主题]

php - 查询在 phpmyadmin 中有效,但在 PHP 脚本中无效

javascript - 隐藏除第一个子级之外的所有子级 div。当我从第一个 div 选择一个单选选项时,显示第二个

php - 如何在php中将html标签转换成字符串

php - 将音频上传到服务器PHP android

php - Opencart product.tpl 未更新

php - Opencart SEO 打破分类直接

php - 尝试更新表名时出错 "order"