Notifier Trace for Zen Cart 1.3.9, 1.5.0, 1.5.1, 1.5.2, 1.5.3

Version 2.1.0 by lat9

Current Support Thread at Zen Cart Forums: http://www.zen-cart.com/forum/showthread.php?t=155383

Version History:

What it does

This plugin captures the output of each base-class notifier call — along with the date, time and main_page — and saves the information to a file (either /logs/notifier_trace.log for Zen Cart versions v1.5.1 and later or /cache/notifier_trace.log for previous versions) for later inspection. Each line of the file is formatted as:

yyyy-mm-dd hh:mm:ss [main_page=page name] Notification text

The trace output is controlled by two configuration settings, one for store-side tracing and one for admin-side tracing, available in your admin's Configuration->Logging once you have applied the SQL patch present in /zen_trace_install.sql:

  1. Enable the notifier-trace for your store?
  2. Enable the notifier-trace for your admin?

Each of these settings can be set to a variety of values, allowing you to control the scope of the trace output for each "environment":

Setting the value to: Causes the trace to be …
blank … totally disabled.
* … enabled for all accesses.
An IP address (either IPv4 or IPv6) … limited to accesses made by that IP address.
An integer value greater than 0 … limited to accesses made by that customer_id or admin_id.

How to use it

Within any functions in non-class code that you want to debug (normal included or required files do not need this statement), include a statement of the form:

global $zco_notifier; // include this once, prior to the first use $zco_notifier->notify('string and constant values'[, array_of_values[, modifiable parms 2-9]]);

This will also aid you in your debugging of classes, so long as the class is defined as:

class class_name extends base;

When you want to see the internals of your class, use the form:

$this->notify('string and constant values'[, array_of_values[, modifiable parms 2-9]]);

All the information will be present in the notifier_trace.log file, in the order that the statements were executed.

Notes:

  1. The notifier_trace.log file can get very big very quickly, so you need to delete it periodically during your debug. For Zen Cart installations of v1.5.0 and later, you can use the Display Logs plugin to view and delete this file during your debug.
  2. I would not recommend using this in a heavy-traffic live store, due to possible performance degradation.

Installation

Depending on your Zen Cart version, there is either one or no core-file overwritten by this plugin. You should always backup your cart’s database and files prior to making any changes.

  1. Create a backup of your Zen Cart's database and files.
  2. If you currently have a version of Zen Notifier Trace prior to v2.0.0 installed, you'll need to remove two files from your Zen Cart before installing the updated version:
    1. /includes/auto_loaders/overrides/config.core.php
    2. /includes/classes/class.base_trace.php
  3. Run the /zen_trace_install.sql file provided by this plugin. Go to your admin's Tools->Install SQL Patches; from there you can either upload the .sql file or copy and paste the contents of the file.
  4. If you are installing this plugin on a Zen Cart version prior to v1.5.3:
    1. Copy the file /before_zc153/includes/classes/class.base.php to your store's /includes/classes directory. This is the version of the file distributed with the Zen Cart v1.5.3 release.
  5. Rename the YOUR_ADMIN directory to match the name of your Zen Cart's admin directory and then copy the new files to your Zen Cart installation directory:
    1. /includes/auto_loaders/config.notifier_trace.php
    2. /includes/init_includes/init_notifier_trace.php
    3. /YOUR_ADMIN/includes/auto_loaders/config.notifier_trace_admin.php

Un-install

Run the zen_trace_uninstall.sql file to remove the database entry, then delete any files you previously copied.