Public Member Functions | Static Public Member Functions | Data Fields
Debug Class Reference

Offers support for debugging php errors, displaying variables, and other messages within a web application. All these features are turned off when the website enters production mode. More...

Public Member Functions

 Debug ($dev_stage, $log_exceptions, $log_exceptions_file)
 
 display ($msg= 'Unknown', $level= 'debug')
 
 variable ($var, $level=0)
 
 exception (Exception $e)
 

Static Public Member Functions

static getInstance ($dev_stage=true, $log_exceptions= '', $log_exceptions_file= '')
 

Data Fields

 $debug_head_color = array()
 
 $debug_div_style
 
 $debug_h1_style
 
 $debug_p_style
 
 $dev_stage
 
 $log_exceptions
 
 $log_exceptions_file
 
 $instance = null
 

Detailed Description

Offers support for debugging php errors, displaying variables, and other messages within a web application. All these features are turned off when the website enters production mode.

Version
1.1
Author
DinuSV

To debug variables, just use variable( $var, $level = 0 ) function :

$example = 20;
$this->debug->variable($example);

Array-type variables can be structured into a multi-level ierarchy. Sometimes extending them in order to visualize all their fields can become ugly due to their huge size. This is where the $level parameter comes into play. You can limit the display of an array to a certain number of levels, by setting the level parameter.

$example = array(
'one' => 1,
'two' => 2,
'twoext' => array('twoA' => 20, 'twoB' => 21)
);
$this->debug->variable($example, 2); // shows 2 of it's subarrays( in this case all )
$this->debug->varialbe($example, 1); // shows only the main array ( 'one', 'two' )

Member Function Documentation

static getInstance (   $dev_stage = true,
  $log_exceptions = '',
  $log_exceptions_file = '' 
)
static

Singleton class

Parameters
$dev_stageboolean : true, if it's development stage
$log_exceptionsboolean : true, if exceptions should be logged
$log_exceptions_filestring : path to the log file
Debug (   $dev_stage,
  $log_exceptions,
  $log_exceptions_file 
)

Constructor

See Also
getInstance
display (   $msg = 'Unknown',
  $level = 'debug' 
)

Display message

Parameters
$msgstring/array : the message(s) to be displayed
$levelstring : type of message(s) to be displayed
variable (   $var,
  $level = 0 
)

Prints the get $var contents using the 'getVarContents' function

Parameters
$var: the variable to be printed
integer$level: variable deepness in case of object or array
exception ( Exception  $e)

Function for outputing the exception

Parameters
Exception$e: the exception to the output

Field Documentation

$debug_head_color = array()

array : Maps color of header with different error types

$debug_div_style

string : Style of the div containing the message

$debug_h1_style

string : Style of the title of the div containing the message

$debug_p_style

string : Stype of the paragraph containing the message

$dev_stage

bool : The stage of the project, set from the config file

$log_exceptions

bool : Log exceptions setting, set from the config file

$log_exceptions_file

string : File to log exceptions to, set from the config file

$instance = null

Debug : Singleton instance