Make WordPress Core


Ignore:
Timestamp:
01/08/2019 03:41:38 AM (6 years ago)
Author:
pento
Message:

Bootstrap: Allow WP_DEBUG_LOG to override the debug.log location.

Setting WP_DEBUG_LOG to a file path will now cause the debug log to be written to that file, rather than the default WP_CONTENT_DIR/debug.log.

Props SergeyBiryukov, ethitter, sebastian.pisula, nacin.
Fixes #18391.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r43983 r44453  
    308308 * as false will force errors to be hidden.
    309309 *
    310  * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
    311  * directory.
     310 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
     311 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
    312312 *
    313313 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
    314314 *
    315315 * @since 3.0.0
     316 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
    316317 * @access private
    317318 */
     
    342343        }
    343344
    344         if ( WP_DEBUG_LOG ) {
     345        if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) {
     346            $log_path = WP_CONTENT_DIR . '/debug.log';
     347        } elseif ( is_string( WP_DEBUG_LOG ) ) {
     348            $log_path = WP_DEBUG_LOG;
     349        } else {
     350            $log_path = false;
     351        }
     352
     353        if ( $log_path ) {
    345354            ini_set( 'log_errors', 1 );
    346             ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
     355            ini_set( 'error_log', $log_path );
    347356        }
    348357    } else {
Note: See TracChangeset for help on using the changeset viewer.