Skip to content

Latest commit

 

History

History
87 lines (43 loc) · 3.16 KB

File metadata and controls

87 lines (43 loc) · 3.16 KB

WP_CLI::debug()

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


Usage

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

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.


Related