diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-02-16 11:52:05 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-02-16 11:52:05 +0100 |
commit | 78361632ede7770a5ee42b88bed0a9506b1fcb66 (patch) | |
tree | b97b1694e4b7e520c4648d9e026a96a6c89a274c /inc/HTTPClient.php | |
parent | 36625b969932ea8641dc1fd0461d4302c600a2a1 (diff) | |
download | rpg-78361632ede7770a5ee42b88bed0a9506b1fcb66.tar.gz rpg-78361632ede7770a5ee42b88bed0a9506b1fcb66.tar.bz2 |
better HTTPClient debug output on CLI
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r-- | inc/HTTPClient.php | 28 |
1 files changed, 28 insertions, 0 deletions
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 <andi@splitbrain.org> */ 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 '<b>'.$info.'</b> '.($this->_time() - $this->start).'s<br />'; if(!is_null($var)){ ob_start(); @@ -684,6 +700,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 */ static function _time(){ |