Skip to content

Commit

Permalink
Added option to dump_xdebug to log file. This can be enabled from deb…
Browse files Browse the repository at this point in the history
…ug_all.php form.

git-svn-id: http://voip.null.ro/svn/ansql/trunk@163 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9
  • Loading branch information
monica committed Apr 10, 2015
1 parent 80fd863 commit 8ffe693
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
15 changes: 11 additions & 4 deletions debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ public static function xdebug($tag, $message=null)
$tag = $default_tag;
}
if (!$message) {
self::output("Error in Debug::debug() tag=$tag, empty message in .");
self::output("critical","Error in Debug::debug() tag=$tag, empty message in .",false);
return;
}
if ( ($debug_all==true && !in_array($tag,$debug_tags)) ||
($debug_all==false && in_array($tag,$debug_tags)) ) {
$date = gmdate("[D M d H:i:s Y]");
self::concat_xdebug("\n$date".strtoupper($tag).": ".$message);
if (!isset($_SESSION["dump_xdebug"]))
self::concat_xdebug("\n$date".strtoupper($tag).": ".$message);
else
self::output($tag, $message, false);
}
}

Expand All @@ -260,15 +263,19 @@ public static function trace()
* If $logs_in is not configured default is $logs_in = array("web")
* @param $tag String Tag for the message
* @param $msg String Message to pe logged/printed
* @param $write_to_xdebug Bool. Default true. Write to xdebug log on not.
* Set to false when called from inside xdebug to avoid loop
*/
public static function output($tag,$msg=NULL)
public static function output($tag,$msg=NULL,$write_to_xdebug=true)
{
global $logs_in;

// log output in xdebug as well
// if xdebug is written then this log will be duplicated
// but it will help debugging to have it inserted in appropriate place in xdebug log
self::xdebug($tag,$msg);
if ($write_to_xdebug)
self::xdebug($tag,$msg);

if ($msg==null && strpos($tag," ")) {
$msg = $tag;
$tag = "output";
Expand Down
20 changes: 14 additions & 6 deletions debug_all.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<head>
<title> Debug Page </title>
<link type="text/css" rel="stylesheet" href="../css/main.css" />
<script language="javascript" type="text/javascript" src="javascript.js"></script>
</head>
<body>
<?php
Expand Down Expand Up @@ -78,15 +79,17 @@ function debug()

$display_errors = (ini_get("display_errors")) ? 't' : 'f';

$dump_xdebug = (isset($_SESSION["dump_xdebug"])) ? "t" : "f";
$debug_queries = (isset($_SESSION["debug_all"])) ? "t" : "f";
$log_errors = (ini_get("log_errors")) ? "t" : "f";
$error_log = ($a = ini_get("error_log")) ? $a : '';
$arr = array(
"pass_debug"=>array("compulsory"=>true, "column_name"=>"Password"),
"debug_queries"=>array("value"=>$debug_queries, "display"=>"checkbox"),
"error_reporting"=>array($errors, "display"=>"select"),
"display_errors"=>array("value"=>$display_errors, "display"=>"checkbox"),
"log_errors"=>array("value"=>$log_errors, "display"=>"checkbox"),
"pass_debug"=>array("compulsory"=>true, "column_name"=>"Password", "comment"=>"Password to be allowed to modify the debugging options (set in config.php usually)"),
"dump_xdebug"=>array("value"=>$dump_xdebug, "display"=>"checkbox", "comment"=>"Dump xdebug log in log file - not the php xdebug, but application and library specific xdebug."),
"debug_queries"=>array("value"=>$debug_queries, "display"=>"checkbox", "comment"=>"Dump query log in log file."),
"error_reporting"=>array($errors, "display"=>"select", "comment"=>"Controls php error_reporting. If set it will be kept in session and it will modify error_reporting until logging out or modifying it again from this form."),
"display_errors"=>array("value"=>$display_errors, "display"=>"checkbox", "comment"=>"Controls php display_errors. If set it will be kept in session and it will modify error_reporting until logging out or modifying it again from this form."),
"log_errors"=>array("value"=>$log_errors, "display"=>"checkbox", "comment"=>"Controls php log_errors. If set it will be kept in session and it will modify error_reporting until logging out or modifying it again from this form."),
"error_log"=>array("value"=>$error_log/*, "display"=>"checkbox"*/)
);

Expand All @@ -111,11 +114,16 @@ function debug_database()
return;
}

if(getparam("debug_queries") == "on")
if (getparam("debug_queries") == "on")
$_SESSION["debug_all"] = "on";
else
unset($_SESSION["debug_all"]);

if (getparam("dump_xdebug") == "on")
$_SESSION["dump_xdebug"] = "on";
else
unset($_SESSION["dump_xdebug"]);

$err = getparam("error_reporting");
$error_reporting = NULL;
foreach($array as $key=>$value) {
Expand Down

0 comments on commit 8ffe693

Please sign in to comment.