WP_CLI::debug() Edit

Display debug message prefixed with "Debug: " when --debug is used.

Usage Usage

WP_CLI::debug( $message, $group = false )
$message (string) Message to write to STDERR.
$group (string|bool) Organize debug message to a specific group.
@return (null)

Top ↑

Notes Notes

Debug message is written to STDERR, and includes script execution time.

Helpful for optionally showing greater detail when needed. Used throughout
WP-CLI bootstrap process for easier debugging and profiling.

# Called in `WP_CLI\Runner::set_wp_root()`.
private static function set_wp_root( $path ) {
    define( 'ABSPATH', Utils\trailingslashit( $path ) );
    WP_CLI::debug( 'ABSPATH defined: ' . ABSPATH );
    $_SERVER['DOCUMENT_ROOT'] = realpath( $path );

# Debug details only appear when `--debug` is used.
# $ wp --debug
# [...]
# Debug: ABSPATH defined: /srv/www/wordpress-develop.dev/src/ (0.225s)

Use false to not group the message.

Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.

Top ↑