[TomatoCart] – A daily error log system for your store.

By default in Tomatocart, there isn’t an error log system to record the errors that may have occurred in your store. Sometimes, you might just notice that your store no longer functions as it should but even then, you don’t know the error that caused it. Finally, you have to ask your the developer debug the system manually to find the reason of the problem. A daily log system is used to track the error for your system so that you could find the detailed error effectively and then clear it.

  • The log files is stored under includes/logs fold.
  • Every log file is named with format such as tomatocart-2015-12-20.log.

Snip20151220_7

As above screenshot shown, you could find the detailed error message and which file the error happened within the log file for 2015-12-20. Any error thrown during that day will be tracked in this file prefixed with a specific time.

How to integrate this log system into your store?

Step 1. Create a composer.json file under TomatoCart root directory with following content:

{
    "config": {
        "vendor-dir": "ext"
    },
    "require": {
        "monolog/monolog": "^1.17",
        "symfony/debug": "^3.0"
    },
    "autoload": {
        "psr-4": { "TC\\Front\\Library\\": "includes/classes" }
    }
}

Note: you have to install the composer. If you haven’t installed it, please read my another article ahttp://blog.arvixe.com/tomatocart-use-composer-to-manage-php-dependency-in-tomatocart/

 

Step 2. Run following command to install the libraries:

composer install

Step 3. Open includes > application_top.php with your favourite editor.

— Find following line:

define('PROJECT_VERSION', 'TomatoCart v1.1.8.6');

— Add following code after it:

include_once('ext/autoload.php');
  $log = new Monolog\Logger('tomatocart');
  $log_handler = new Monolog\Handler\RotatingFileHandler(DIR_FS_CATALOG . 'includes/logs/tomatocart.log', 5);
  $log_handler->setFormatter(new Monolog\Formatter\LineFormatter(null, null, true, true));
  $log->pushHandler($log_handler);
  $exception_handler = new TC\Front\Library\HandleExceptions($log);

Step 4. Open admin > includes > application_top.php with your favourite editor.

 

— Find following line:

define('PROJECT_VERSION', 'TomatoCart v1.1.8.6');

— Add following code after it:

include_once('../ext/autoload.php');
  $log = new Monolog\Logger('tomatocart');
  $log_handler = new Monolog\Handler\RotatingFileHandler(DIR_FS_CATALOG . 'includes/logs/tomatocart.log', 5);
  $log_handler->setFormatter(new Monolog\Formatter\LineFormatter(null, null, true, true));
  $log->pushHandler($log_handler);
  $exception_handler = new TC\Front\Library\HandleExceptions($log);

That’s it. It’s not difficult to complete above steps. Please try it by yourself.

I will arrange time to implement a log module in the admin panel so that you could verify the error log directly in the admin panel.

Looking for quality TomatoCart hosting? Check out Arvixe Web Hosting

Tags: | Posted under TomatoCart | RSS 2.0

Author Spotlight

Jack Yin

TomatoCart Developer & Co Founder - Arvixe Web Hosting / TomatoCart Community Liaison

Leave a Reply

Your email address will not be published. Required fields are marked *