PHP Logger
The plugin includes a Logger class for recording debug information during PHP execution. Logs are stored in wp_options and are viewable from the plugin’s admin debug panel.
Accessing the Logger
$logger = wp3dconf()->logger;
Methods
| Method | Level | Description |
|---|---|---|
info( $message, $context ) | INFO | General informational messages |
warning( $message, $context ) | WARNING | Non-critical issues worth monitoring |
error( $message, $context ) | ERROR | Failures that need attention |
debug( $message, $context ) | DEBUG | Verbose development output |
$logger = wp3dconf()->logger;
$logger->info( 'Order submitted', [ 'order_id' => 123 ] );
$logger->warning( 'API rate limit approaching', [ 'requests' => 950, 'limit' => 1000 ] );
$logger->error( 'Payment failed', [ 'order_id' => 456, 'reason' => 'Card declined' ] );
$logger->debug( 'Processing step', [ 'step' => 'validation', 'order_id' => 789 ] );
What Each Entry Captures
Every log entry automatically records:
| Field | Description |
|---|---|
timestamp | MySQL datetime at time of logging |
level | INFO, WARNING, ERROR, or DEBUG |
message | The message string |
context | The $context array |
file | Basename of the calling file |
line | Line number of the calling code |
user_id | ID of the currently logged-in WordPress user |
ip | Remote IP address |
Retrieving & Exporting Logs
$logger = wp3dconf()->logger;
// Get all stored log entries
$logs = $logger->get_logs();
// Export as plain text — useful for support tickets or bug reports
$text = $logger->export_as_text();
// Clear all stored logs
$logger->clear_logs();
Logs are stored in wp_options under the key wp3dconf_debug_logs, newest first, capped at the last 50 entries.
Usage in an Addon
add_action( 'wp3dconf/frontend/before_skin_display', function( $skin_instance, $post_id ) {
wp3dconf()->logger->debug( 'Rendering skin', [
'skin_id' => $skin_instance->get_skin_id(),
'post_id' => $post_id,
] );
}, 10, 2 );