From 78361632ede7770a5ee42b88bed0a9506b1fcb66 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 16 Feb 2013 11:52:05 +0100 Subject: better HTTPClient debug output on CLI --- inc/HTTPClient.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 51c1de875..8cfb86567 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -669,10 +669,26 @@ class HTTPClient { /** * print debug info * + * Uses _debug_text or _debug_html depending on the SAPI name + * * @author Andreas Gohr */ function _debug($info,$var=null){ if(!$this->debug) return; + if(php_sapi_name() == 'cli'){ + $this->_debug_text($info, $var); + }else{ + $this->_debug_html($info, $var); + } + } + + /** + * print debug info as HTML + * + * @param $info + * @param null $var + */ + function _debug_html($info, $var=null){ print ''.$info.' '.($this->_time() - $this->start).'s
'; if(!is_null($var)){ ob_start(); @@ -683,6 +699,18 @@ class HTTPClient { } } + /** + * prints debug info as plain text + * + * @param $info + * @param null $var + */ + function _debug_text($info, $var=null){ + print '*'.$info.'* '.($this->_time() - $this->start)."s\n"; + if(!is_null($var)) print_r($var); + print "\n-----------------------------------------------\n"; + } + /** * Return current timestamp in microsecond resolution */ -- cgit v1.2.3