Logger module

Learn more about the Logger module.

This module is useful for logging events related to products, orders, and charges. You can enable or disable logging directly from the Settings page WooCommerce->Settings->Payment(tab).

All the logs are written to the uploads/digitalriver/logs directory. View the logs from the Admin Dashboard by going to WooCommerce->Status->Logs.

Specifications

This module logs data for all the modules.

The log method will be triggered for the following API calls:

  • SKU–Product Sync API calls

  • Order–status and transaction API calls

  • Customer–read and created into Digital River API calls

  • Checkout–created and updated API calls

  • Tax calculation–API calls

All logs are written to specific folder-wise log files if logging is enabled from gateway settings. Find the settings in WooCommerce by selecting Settings and clicking the Payment tab under the Digital River Gateway section. The transaction details are displayed in a meta box on the Order Edit page.

The relationship between the WooCommerce order and the Digital River order is maintained by storing the Digital River order ID as order post_meta managed by the order sync module.

The Logger module will only fetch the dr_order_id meta value and display the logs of that order. A new log file will be created for each object.

Naming conventions

  • Order related log files will be stored in uploads/digitalriver/logs/orders/[order_id].log.

  • SKU related logs will go to the uploads/digitalriver/logs/products/[product_id].log log file.

  • Customer related logs will go to the uploads/digitalriver/logs/customers/[customer_id].log log file.

  • Checkout related logs will go to the uploads/digitalriver/logs/checkouts/[checkout_id].log log file.

  • Payment Source related logs will go to the uploads/digitalriver/logs/sources/[source_id].log log file.

  • Any other logs will go to the uploads/digitalriver/logs/default.log file.

  • Error logs will go to the uploads/digitalriver/logs/errors.log file.

How to log an object

Trigger the action digitalriver.api_success with the following three parameters:

  • Object

  • Event name

  • Action type (CREATE / UPDATE / DELETE)

    Example: do_action( 'digitalriver.api_success', $object, $event, $action )

Currently, the following objects are supported as a stand-alone. The remaining objects are handled by the GenericHandler.

  • Checkout

  • Customer

  • Order

  • SKU

  • Source

  • Throwable

Customize how to log an object

To customize how to log an object:

  1. Create a new object extending the GenericHandler.

  2. Modify the methods get_log_line and get_relative_path as per your requirements.

  3. Add a new method to the dr_log_handler hook.

  4. The method must check whether the classname matches the object of interest and then return the newly created Handler object.

Log an error

Trigger the action digitalriver.api_error with the error as a parameter. Example: do_action( 'digitalriver.api_error', $exception )

Logger methods

Logger class

This class listens to events and logs them by using different Handlers for logging data types.

Logger Container class

This class acts as a Dependency Injection container for providing dependencies to classes present in the Logger module.

Logger View class

This class takes care of adding a new tab where the digitalriver logs can be displayed in the WooCommerce Status Menu tab.

Metabox class

This class adds a metabox to the Order Edit page to display the order-related logs. The logs are fetched from the log file.

Interfaces

The Logger module defines the Handler and ErrorHandler interfaces.

Handler interface

This interface declares a single method that must be implemented by all the Handlers. A new Handler class must be created for every object type.

Error Handler interface

This interface declares a single method that must be implemented by Error Handlers.

Handler classes

The following table describes the Handler classes:

Last updated