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:
| Value | Level | Description |
|---|---|---|
100 | DEBUG | All logs (verbose) |
200 | INFO | Informational messages |
250 | NOTICE | Notable events |
300 | WARNING | Default โ unexpected conditions |
400 | ERROR | Runtime errors |
500 | CRITICAL | Critical conditions |
550 | ALERT | Immediate action required |
600 | EMERGENCY | System 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 errorskount-{date}.logโ Kount fraud eventsangelleye_ppcp-{date}.logโ PayPal PPCP errorscryptowoo-{date}.logโ Crypto payment eventsscottsdale-ach-gateway-{date}.logโ ACH gateway errors
Error Levels by Environmentโ
| Environment | PHP Error Reporting | WordPress Debug | Wonolog Level |
|---|---|---|---|
| Local | E_ALL | WP_DEBUG=true, WP_DEBUG_LOG=true | 100 (DEBUG) |
| Development | E_ALL | WP_DEBUG=true | 100 (DEBUG) |
| Staging | E_ERROR | Off | 300 (WARNING) |
| Production | E_ERROR | Off | 300 (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