Skip to main content

Logging & Monitoring

Scottsdale Mint uses structured JSON logging via Wonolog, integrated with AWS CloudWatch in production, and file-based logging locally.


Wonolog Logging Stackโ€‹

Library: Inpsyde Wonolog (Monolog-based WordPress logging) MU Plugin: web/app/mu-plugins/wonolog.php Vendor packages: vendor-static/inpsyde/, vendor-static/monolog/

Configurationโ€‹

// wonolog.php (mu-plugin)

// Custom SUMA log channel
$channel = new \Monolog\Logger('SUMA');

// Production (Ymir/Lambda): Log to PHP stderr (captured by CloudWatch)
// Development: Log to local file
$handler = \Ymir\isProduction()
? new StreamHandler('php://stderr')
: new StreamHandler(WP_CONTENT_DIR . '/suma.log');

$handler->setFormatter(new JsonFormatter());

$channel->pushHandler($handler);

Minimum Log Levelโ€‹

Controlled by the WONOLOG_DEFAULT_MIN_LEVEL environment variable:

ValueLevelDescription
100DEBUGAll logs (verbose)
200INFOInformational messages
250NOTICENotable events
300WARNINGDefault โ€” unexpected conditions
400ERRORRuntime errors
500CRITICALCritical conditions
550ALERTImmediate action required
600EMERGENCYSystem unusable

Log Formatโ€‹

All logs are structured JSON for easy parsing in CloudWatch Logs Insights:

{
"message": "Price update failed for product 1234",
"context": {
"product_id": 1234,
"sku": "SM-1OZ-SILVER-BAR",
"error": "Invalid spot price returned from NFusion"
},
"level": 400,
"level_name": "ERROR",
"channel": "SUMA",
"datetime": "2026-03-26T14:30:00.000000+00:00"
}

Using the Logger in Custom Codeโ€‹

The theme and plugins use the \Suma\Logger integration class (via sumatra-logger plugin):

use Suma\Logger;

// Log a warning
Logger::warning( 'Unexpected payment status', [
'order_id' => $order_id,
'status' => $status,
'gateway' => $gateway_id,
] );

// Log an error
Logger::error( 'Kount ENS callback failed', [
'order_id' => $order_id,
'response' => $kount_response,
] );

Kount Fraud Loggingโ€‹

The Kount-Remove-Unecessary-Logging.patch removes verbose Kount debug output that was flooding logs. Kount fraud decisions are logged at the WARNING level when an order is declined, and at INFO when approved.

Kount logs are stored in: /uploads/kount_logs.log (local development)


NewRelic APMโ€‹

Plugin: wp-newrelic ^1.3

Featuresโ€‹

  • Transaction tracing โ€” Full PHP stack traces per request
  • Error tracking โ€” PHP exceptions and fatal errors
  • Database query analysis โ€” Slow query detection
  • External API monitoring โ€” NFusion, Plaid, Klaviyo, Kount call timing
  • Custom metrics โ€” Precious metals transaction counts, pricing update frequency

When to Use NewRelicโ€‹

  • Investigating slow page loads
  • Tracking down N+1 database queries
  • Monitoring Lambda cold start frequency
  • Alerting on API timeout spikes (e.g., NFusion pricing timeouts)

CloudWatch Logs (Production)โ€‹

In production, all PHP stderr output (including Wonolog JSON logs) is automatically captured by AWS CloudWatch Logs. Access via the AWS Console or via Ymir:

# Tail Lambda logs for production
ymir logs production --tail

# View recent logs
ymir logs production

Useful CloudWatch Query (Logs Insights)โ€‹

fields @timestamp, message, context.order_id, context.error
| filter channel = "SUMA" and level >= 400
| sort @timestamp desc
| limit 50

WooCommerce Status Logsโ€‹

WooCommerce has its own built-in logging system accessible at: WP Admin โ†’ WooCommerce โ†’ Status โ†’ Logs

Key log files to check for payment debugging:

  • woocommerce-{date}.log โ€” General WC errors
  • kount-{date}.log โ€” Kount fraud events
  • angelleye_ppcp-{date}.log โ€” PayPal PPCP errors
  • cryptowoo-{date}.log โ€” Crypto payment events
  • scottsdale-ach-gateway-{date}.log โ€” ACH gateway errors

Error Levels by Environmentโ€‹

EnvironmentPHP Error ReportingWordPress DebugWonolog Level
LocalE_ALLWP_DEBUG=true, WP_DEBUG_LOG=true100 (DEBUG)
DevelopmentE_ALLWP_DEBUG=true100 (DEBUG)
StagingE_ERROROff300 (WARNING)
ProductionE_ERROROff300 (WARNING)

Log Retention Policyโ€‹

  • CloudWatch Logs: Configured in AWS Console (typically 30-90 days for Lambda)
  • Local log files: Not automatically rotated โ€” clear manually during development
  • WooCommerce logs: Auto-cleaned after 30 days by WooCommerce's scheduled cleanup