| 开发者 | rahuliprajapati |
|---|---|
| 更新时间 | 2026年7月18日 15:39 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
debug.log file. RP Debug Log Viewer turns chaotic WordPress debugging into a fast, focused workflow — right inside your admin dashboard. Create custom log files for any feature — payments, APIs, cron jobs, custom code — and capture rich context with every entry: error codes, file names, line numbers, and more. A beautiful, color-coded log viewer lets you scan, search, and filter entries instantly, so you spot exactly what broke and where — in seconds, not hours. Toggle, download, or clear any log in one click. And with the built-in PHP Snippets manager, you can drop in hooks, filters, and temporary debugging code straight from the admin panel — no FTP, no functions.php edits, no extra snippet plugin. Whether you're a developer hunting a stubborn bug, a researcher analyzing patterns, or a site owner who just wants answers, RP Debug Log Viewer makes debugging effortless, organized, and genuinely enjoyable.
PHP Snippets — Run Debug Code Without Another Plugin
The Snippets page lets administrators create and manage small PHP snippets for WordPress debugging and development:
define( 'RP_DLV_SNIPPETS_SAFE_MODE', true ); to wp-config.php and all snippet execution stops instantly.rp_trace() helper that dumps any variable into the Log Viewer from anywhere in your code, a 404 logger, a request performance monitor, login/email/post-save loggers — each added Inactive so you can review the code first.plugins_loaded) while active — ideal for hooks, filters, actions, debugging functions, temporary custom code, and testing new features.
Why Use RP Debug Log Viewer?
error_log() was more organized.INFO, WARNING, ERROR, DEBUG — each color-coded with distinctive badges so you can scan logs at a glance.$_POST, WooCommerce carts, or user objects.wp-content/debug.log file is automatically available as a built-in, read-only tab, so you can view and search PHP errors and WordPress notices alongside your custom logs. To keep the plugin from writing outside its own directory, this tab supports view, search, and download only — it is never modified or cleared by the plugin.RP_DLV_SNIPPETS_SAFE_MODE constant acts as an instant kill switch for all snippets.rp_trace() variable inspector, 404 logger, request performance monitor, user login logger, post-save data dumper, and outgoing email logger.rp_dlv_*() calls targeting it are silently skipped.rp-debug-log-viewer text domain.rp_dlv_info( 'my-plugin', 'User registered successfully', [ 'user_id' => 42 ] );
Step 3. Open RP Debug Log Viewer in your admin sidebar and click the tab for your log file. That's it.
Available Functions
Five global helper functions are available as soon as the plugin is active:
rp_dlv_info( $log_name, $message, $context = [] )
rp_dlv_warning( $log_name, $message, $context = [] )
rp_dlv_error( $log_name, $message, $context = [] )
rp_dlv_debug( $log_name, $message, $context = [] )
rp_dlv_log( $log_name, $message, $level = 'info', $context = [] )
.log). If it does not exist, it is created automatically.add_action( 'wp_login', function( $login, $user ) {
rp_dlv_info( 'auth', 'Login: ' . $login, [ 'id' => $user->ID ] );
}, 10, 2 );
Log a remote API call:
$response = wp_remote_get( $url );
if ( is_wp_error( $response ) ) {
rp_dlv_error( 'api', $response->get_error_message(), [ 'url' => $url ] );
} else {
rp_dlv_info( 'api', 'Success', [ 'status' => wp_remote_retrieve_response_code( $response ) ] );
}
Log WooCommerce payment events:
add_action( 'woocommerce_payment_complete', function( $order_id ) {
rp_dlv_info( 'woocommerce', 'Payment complete', [ 'order_id' => $order_id ] );
} );
Dump a full PHP array for inspection:
$cart = WC()->cart->get_cart();
rp_dlv_debug( 'woocommerce', $cart );
Measure execution time:
$start = microtime( true );
$result = heavy_import();
rp_dlv_info( 'import', 'Finished', [ 'elapsed_ms' => round( ( microtime(true) - $start ) * 1000, 2 ) ] );
How Log Files Are Stored
Custom log files are stored in wp-content/uploads/rp-debug-log-viewer/. The directory is automatically protected:
.htaccess file blocks direct HTTP access to all log files.index.php file prevents directory listing.debug.log (in wp-content/) is also viewable, searchable, and downloadable as a built-in tab — but it is never written to, cleared, or deleted by this plugin, since that file lives outside the plugin's own directory and is owned by WordPress core.
Security
manage_options capability (administrator only).sanitize_file_name() and basename(), then re-validated against a canonicalized (realpath()) allow-list so a request can never resolve outside wp-content/uploads/rp-debug-log-viewer/ — even via directory traversal or symlink tricks.wp-content/uploads/rp-debug-log-viewer/. The plugin never writes to, clears, or deletes wp-content/debug.log; that file is read-only within the plugin.sanitize_text_field(), sanitize_hex_color(), and absint().esc_html(), esc_attr(), and esc_url().admin_init handler — files are never served via a public URL..htaccess and index.php guards.$wpdb->prepare() with parameterized placeholders.rp-debug-log-viewer folder to the /wp-content/plugins/ directory, or install directly from the WordPress plugin repository via Plugins -> Add New and search for "RP Debug Log Viewer".rp_dlv_info(), rp_dlv_warning(), rp_dlv_error(), or rp_dlv_debug().rp_trace() variable inspector.No. Calling any rp_dlv_*() function with a new log name automatically creates the file, registers it in the database, and adds it as a tab in the viewer. You can also create log files manually from the Log Viewer page using the "Create Custom Log File" form.
In wp-content/uploads/rp-debug-log-viewer/. Each file is named <log-name>.log. The directory is protected from direct browser access with an .htaccess file and an index.php guard.
Yes. The debug log is pre-registered and appears as the first tab in the viewer. It reads from the standard wp-content/debug.log file, and you can view, search, and download it like any other log. It cannot be cleared or deleted through the plugin, since wp-content/debug.log is owned by WordPress core and lives outside the plugin's own storage directory — this plugin never writes to it. To clear it, disable and re-enable WP_DEBUG_LOG in wp-config.php, or clear it manually via your host's file manager or SSH.
Yes. Go to RP Debug Log Viewer -> Configuration -> Tab Management and toggle the log to Inactive. All rp_dlv_*() calls targeting that log will be silently skipped until it is re-activated. The log file itself is preserved — only new writes are paused.
No. RP Debug Log Viewer is designed for zero frontend impact:
file_put_contents() with FILE_APPEND, which is a single fast I/O operation.Yes — with care. Toggle verbose debug logs to Inactive in Configuration so rp_dlv_debug() calls are skipped without touching your code. Keep info and error level logs active for ongoing monitoring. Avoid logging passwords, credit card numbers, or other sensitive personal data.
Yes, as long as RP Debug Log Viewer is loaded before your code runs. Hooking into plugins_loaded at priority 10 or later is the safest approach for plugins. For mu-plugins, the logging functions are available after all regular plugins have loaded.
Snippets are small pieces of PHP code you write and manage from RP Debug Log Viewer -> Snippets — no FTP, no functions.php edits. Use them for hooks, filters, actions, debugging helpers, temporary custom code, or testing a new feature before it goes into your theme or plugin. Only snippets marked Active are executed; everything else just sits safely in the database. Snippets run on every page load during plugins_loaded, so anything you'd normally put in functions.php works the same way.
You can't save broken code. Before a snippet is saved or activated, its code is run through PHP's own parser (without being executed). If there is a syntax error, the save is rejected and you see the exact problem and line number. If an already-active snippet fails at runtime (for example, it calls a function that doesn't exist), the error is caught, the snippet is automatically deactivated so it cannot crash subsequent requests, and an admin notice shows you what went wrong and where. As an emergency brake, adding define( 'RP_DLV_SNIPPETS_SAFE_MODE', true ); to wp-config.php disables all snippet execution instantly while keeping your snippets stored. Snippet management requires the manage_options capability (administrators only), and every action is nonce-protected.
The Snippets feature is intentionally PHP-only and focused on WordPress debugging and development. If you need to output CSS or JavaScript, you can still do it the WordPress way from a PHP snippet — for example, by hooking wp_enqueue_scripts or wp_head.
Yes. RP Debug Log Viewer does not modify WordPress constants like WP_DEBUG or WP_DEBUG_LOG. It operates independently using its own log files and does not conflict with Query Monitor, Debug Bar, or any other debugging tool.
All plugin data is cleaned up automatically: the custom database table is dropped, plugin options are removed, and all log files in wp-content/uploads/rp-debug-log-viewer/ are deleted. No orphaned data is left behind.
PHP 7.4 or higher. PHP 8.0, 8.1, 8.2, 8.3, and 8.4 are fully supported.
Yes. All UI strings use WordPress internationalization functions with the rp-debug-log-viewer text domain. A .pot file can be generated with WP-CLI: wp i18n make-pot . languages/rp-debug-log-viewer.pot.
RP_DLV_SNIPPETS_SAFE_MODE wp-config.php constant as an emergency kill switch that disables all snippet execution.rp_trace() variable inspector, 404 logger, request performance monitor, user login logger, post-save data dumper, and outgoing email logger. Samples are always added Inactive for review first.wp_rp_dlv_snippets), created automatically on update and removed on uninstall.manage_options); snippet code is stored via prepared statements and escaped on output.wp-content/debug.log, since it is owned by WordPress core and lives outside the plugin's storage directory).sanitize_file_name() and basename(), then every read/write path is re-validated with realpath() to stay contained within wp-content/uploads/rp-debug-log-viewer/.rp-debug-log-viewer text domain.