Skip to main content

Sumatra Utilities & Sumatra Logger

Locations:

  • web/app/plugins/sumatra-utilities/ โ€” Shared utility library
  • web/app/plugins/sumatra-logger/ โ€” Structured logging integration

Author: Rhino Group


Sumatra Utilitiesโ€‹

Overviewโ€‹

sumatra-utilities is a shared PHP utility library used across all Rhino Group custom plugins and the suma-elementor theme. It provides common helper functions, base classes, and shared functionality to avoid code duplication.

Purposeโ€‹

  • Provides base classes and traits shared across plugins
  • Utility functions for common WordPress/WooCommerce operations
  • Standardized error handling patterns
  • Reusable REST API base classes

Usageโ€‹

Other plugins and the theme include this plugin's functionality via direct PHP inclusion or autoloading. It is always active as it is a dependency.


Sumatra Loggerโ€‹

Overviewโ€‹

sumatra-logger integrates with the Wonolog MU plugin (configured in web/app/mu-plugins/wonolog.php) to provide a clean structured logging API for all Rhino Group custom code.

Usageโ€‹

use Suma\Logger;

// Log levels follow PSR-3
Logger::debug( 'Price calculation started', [ 'product_id' => 1234 ] );
Logger::info( 'Order exported to NFusion', [ 'order_id' => 5678 ] );
Logger::warning( 'Spot price update delayed', [ 'delay_seconds' => 120 ] );
Logger::error( 'Plaid API timeout', [ 'order_id' => 5678, 'attempt' => 3 ] );
Logger::critical( 'iTransact ACH failed', [ 'order_id' => 5678 ] );

Log Outputโ€‹

All logs are written as structured JSON to:

  • Production (Ymir/Lambda): PHP stderr โ†’ CloudWatch Logs
  • Development: Local file at web/app/suma.log

See Logging & Monitoring for full configuration details.

Custom Log Channelโ€‹

All custom code logs to the SUMA channel:

{
"channel": "SUMA",
"level_name": "ERROR",
"message": "Plaid API timeout",
"context": { "order_id": 5678, "attempt": 3 },
"datetime": "2026-03-26T14:30:00+00:00"
}

This makes it easy to filter logs in CloudWatch Logs Insights:

filter channel = "SUMA" and level >= 400