Added debugging-only output function.

git-svn-id: http://yate.null.ro/svn/yate/trunk@684 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2006-02-14 11:41:39 +00:00
parent 0d3dc35b83
commit f943983d4f
1 changed files with 18 additions and 1 deletions

View File

@ -60,6 +60,22 @@ class Yate
fputs($yate_stderr, $str . "\n");
}
/**
* Static function to output a string to Yate's stderr or logfile
* only if debugging was enabled.
* @param $str String to output, or boolean (true/false) to set debugging
*/
static function Debug($str)
{
global $yate_stderr, $yate_debug;
if ($str === true)
$yate_debug = true;
else if ($str === false)
$yate_debug = false;
else if ($yate_debug)
fputs($yate_stderr, $str . "\n");
}
/**
* Static function to convert a Yate string representation to a boolean
* @param $str String value to convert
@ -323,7 +339,8 @@ class Yate
*/
static function Init($async = false)
{
global $yate_stdin, $yate_stdout, $yate_stderr;
global $yate_stdin, $yate_stdout, $yate_stderr, $yate_debug;
$yate_debug = false;
$yate_stdin = fopen("php://stdin","r");
$yate_stdout = fopen("php://stdout","w");
$yate_stderr = fopen("php://stderr","w");