The ezcDebug class provides functionality to format and store debug messages and timers.
The functionality of the Debug component is two folded:
The second parameter of the log method is the verbosity. This is a number that specifies the importance of the log message. That makes it easier to sort out messages of less importance. In this example, we assumed the more important the message, the lower the verbosity number.
The ezcDebug timer is designed to allow the next two timing methods:
To get timing points, accumulators, use the switchTimer() method. This is shown in the next example:
Source for this file: /Debug/src/debug.php
Version: | //autogentag// |
ezcDebugOptions | read/write |
$options
Options to configure the behaviour of ezcDebug, including stack trace behaviours. |
protected array(string=>mixed) |
$properties
= array()
Properties. |
public static void |
debugHandler(
$errno
, $errstr
, $errfile
, $errline
)
Dispatches the message and error type to the correct debug or log function. |
public static ezcDebug |
getInstance(
)
Returns the instance of this class. |
public string |
generateOutput(
)
Returns the formatted debug output. |
public ezcLog |
getEventLog(
)
Returns the instance of the EventLog used in this class. |
public void |
log(
$message
, $verbosity
, [ $extraInfo
= array()] , [ $stackTrace
= false] )
Writes the debug message $message with verbosity $verbosity. |
public void |
reset(
)
Resets the log messages and timer information. |
public void |
setOutputFormatter(
$formatter
)
Sets the formatter $reporter for the output. |
public void |
startTimer(
$name
, [ $group
= null] )
Starts the timer with the identifier $name. |
public void |
stopTimer(
[ $name
= false] )
Stops the timer identified by $name. |
public void |
switchTimer(
$newName
, [ $oldName
= false] )
Stores the time from the running timer, and starts a new timer. |
Dispatches the message and error type to the correct debug or log function.
This function should be used as the set_error_handler from the trigger_error function.
Use for example the following code in your application:
Use trigger_error() to log warning, error, etc:
See the PHP documentation of trigger_error for more information.
Name | Type | Description |
---|---|---|
$errno |
int | |
$errstr |
string | |
$errfile |
string | |
$errline |
int |
Returns the instance of this class.
When the ezcDebug instance is created it is automatically added to the instance of ezcLog.
Returns the formatted debug output.
Returns the instance of the EventLog used in this class.
The returned instance is not the same as retrieved via the ezcLog::getInstance() method.
Writes the debug message $message with verbosity $verbosity.
Arbitrary $extraInfo can be submitted. If $stackTrace is set to true, a stack trace will be stored at the current program position.
Name | Type | Description |
---|---|---|
$message |
string | |
$verbosity |
int | |
$extraInfo |
array(string=>string) | |
$stackTrace |
bool |
Resets the log messages and timer information.
Sets the formatter $reporter for the output.
If no formatter is set ezcDebugHtmlReporter will be used by default.
Name | Type | Description |
---|---|---|
$formatter |
ezcDebugOutputFormatter |
Starts the timer with the identifier $name.
Optionally, a timer group can be given with the $group parameter.
Name | Type | Description |
---|---|---|
$name |
string | |
$group |
string |
Stops the timer identified by $name.
$name can be omitted (false) if only one timer is running.
Name | Type | Description |
---|---|---|
$name |
string|bool |
Stores the time from the running timer, and starts a new timer.
Stores the time for $oldTimer (maybe omitted if only 1 timer is running) and starts a new timer with $newName.
Name | Type | Description |
---|---|---|
$newName |
string | |
$oldName |
string|bool |