WP_CLI::debug PHP Method

debug() public static method

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', rtrim( $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)
public static debug ( string $message, string $group = false ) : null
$message string Message to write to STDERR.
$group string Organize debug message to a specific group.
return null
    public static function debug($message, $group = false)
    {
        self::$logger->debug(self::error_to_string($message), $group);
    }

Usage Example

 protected static function tgz($args, $assoc_args)
 {
     @(list($repo, $tag) = $args);
     $url = sprintf("https://bitbucket.org/%s/get/%s.tar.gz", $repo, $tag ?: 'master');
     if (array_intersect_key($assoc_args, array('key' => TRUE, 'secret' => TRUE))) {
         WP_CLI::debug("Fetching {$url} via OAuth");
         $tgz = self::fetch_tarball_via_oauth($assoc_args['key'], $assoc_args['secret'], $url);
     } else {
         WP_CLI::debug("Fetching {$url} via cURL");
         $tgz = self::fetch_tarball($url);
     }
     WP_CLI::debug("Fetched {$tgz}");
     WP_CLI::debug("Converting {$tgz} to zip");
     $zip = self::tgz_to_zip($repo, $tgz);
     WP_CLI::debug("Converted {$tgz} to {$zip}");
     return array($url, $tgz, $zip);
 }
All Usage Examples Of WP_CLI::debug