3

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?

focus.style
  • 6,612
  • 4
  • 26
  • 38
Jaime Dolor jr.
  • 897
  • 1
  • 11
  • 28

1 Answers1

4

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/

focus.style
  • 6,612
  • 4
  • 26
  • 38