Jai*_*jr. 4 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);
Run Code Online (Sandbox Code Playgroud)
然后我可以检查日志文件。
我该如何在 OpenCart 中执行此操作?
在 OpenCart 2 和 3 中, /system/library/log.php中有日志库
几乎可以从任何地方(从任何模型和控制器)访问该库。您可以轻松地使用它,例如:
$var = 'this is a variable';
//some other code goes here
$this->log->write('Is $var a null? Here is the value '.$var);
Run Code Online (Sandbox Code Playgroud)
您可以在/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);
Run Code Online (Sandbox Code Playgroud)
您将在/system/storage/logs/中找到您的日志文件