Skip to content

Commit

Permalink
Added Debug::func_start to all functions/methods. If logging is not c…
Browse files Browse the repository at this point in the history
…onfigured Debug::Output will trigger a PHP NOTICE that will likely be written in the apache logs.

git-svn-id: http://voip.null.ro/svn/ansql/trunk@98 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9
  • Loading branch information
monica committed Jun 19, 2014
1 parent a5d22d3 commit e57c09d
Show file tree
Hide file tree
Showing 7 changed files with 259 additions and 32 deletions.
10 changes: 10 additions & 0 deletions base_classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

require_once("debug.php");

class Response extends GenericStatus
{
// optional generic $info, in case you need to return a specific object/value
private $info;

public function __construct($status=true, $p1=NULL, $p2=NULL)
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
parent::__construct($status, $p1, $p2);
if ($status)
$this->info = $p1;
Expand All @@ -40,6 +43,7 @@ class GenericStatus

public function __construct($status=true, $p1=NULL, $p2=NULL)
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
$this->status = $status;

if (!$this->status) {
Expand All @@ -55,11 +59,13 @@ public function __construct($status=true, $p1=NULL, $p2=NULL)

public function status()
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
return $this->status;
}

public function setError($p1=NULL,$p2=NULL)
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
$this->status = false;
if (is_numeric($p1)) {
$this->code = $p1;
Expand All @@ -76,6 +82,7 @@ public function setError($p1=NULL,$p2=NULL)
*/
private function setErrorMessage($message)
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
if (isset($this->error_message) && strlen($this->error_message))
$this->error_message .= "\n".$message;
else
Expand All @@ -88,6 +95,7 @@ private function setErrorMessage($message)
*/
private function setErrorCode($code)
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
if (isset($this->code) && strlen($this->code))
return;

Expand All @@ -96,11 +104,13 @@ private function setErrorCode($code)

public function getError()
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
return $this->error_message;
}

public function getErrorCode()
{
Debug::func_start(__METHOD__,func_get_args(),"ansql");
return $this->error_code;
}
}
Expand Down
10 changes: 7 additions & 3 deletions debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

// array of tags that should be included or excluded from debug
// a tag can't contain white spaces
$debug_tags = array("paranoid","in_framework");
$debug_tags = array("paranoid","in_framework","in_ansql","ansql","framework");

// default tag if tag is not specified
$default_tag = "logic";
Expand Down Expand Up @@ -223,8 +223,12 @@ public static function output($tag,$msg=NULL)
return;
}

if (!isset($logs_in))
$logs_in = "web";
// In case we didn't configure a log file just throw this in the apache logs
// The majority of admins/people installing will know to look in apache logs for issues
if (!isset($logs_in)) {
trigger_error("$tag: $msg", E_USER_NOTICE);
return;
}

$arr = $logs_in;
if(!is_array($arr))
Expand Down
Loading

0 comments on commit e57c09d

Please sign in to comment.