current_time( 'mysql' ), 'tool' => $tool, 'user_id' => $user_id, 'destructive' => $destructive, 'success' => ! $is_error, 'execution_ms' => round( $execution_ms, 2 ), 'error' => $is_error ? $result->get_error_message() : null, ]; /** * Filter or intercept MCP audit log entries. * * @param array $log_entry Structured log payload. */ do_action( 'wpfunnels/mcp_audit_log', $log_entry ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( sprintf( '[WPFunnels MCP] %s | User: %d | Tool: %s | Time: %.2fms | Status: %s', $log_entry['timestamp'], $user_id, $tool, $log_entry['execution_ms'], $is_error ? 'ERROR (' . $log_entry['error'] . ')' : 'SUCCESS' ) ); } } }