Zeta Components Manual :: Docs For Class ezcDebug
Debug::ezcDebug
Class ezcDebug
The ezcDebug class provides functionality to format and store debug messages and timers.
The functionality of the Debug component is two folded:
- Debug log messages
- Timers
- // ...
- // ...
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:
- Timers, the time between two points in the program.
- Accumulators, gets the relative time after the script started.
- // Simple calculation
- $result = 4 + 6;
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// |
Properties
ezcDebugOptions | read/write |
$options
Options to configure the behaviour of ezcDebug, including stack trace behaviours. |
Member Variables
protected array(string=>mixed) |
$properties
= array()
Properties. |
Method Summary
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. |
Methods
debugHandler
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.
Parameters:
Name | Type | Description |
---|---|---|
$errno |
int | |
$errstr |
string | |
$errfile |
string | |
$errline |
int |
getInstance
Returns the instance of this class.
When the ezcDebug instance is created it is automatically added to the instance of ezcLog.
generateOutput
Returns the formatted debug output.
getEventLog
Returns the instance of the EventLog used in this class.
The returned instance is not the same as retrieved via the ezcLog::getInstance() method.
log
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.
Parameters:
Name | Type | Description |
---|---|---|
$message |
string | |
$verbosity |
int | |
$extraInfo |
array(string=>string) | |
$stackTrace |
bool |
reset
Resets the log messages and timer information.
setOutputFormatter
Sets the formatter $reporter for the output.
If no formatter is set ezcDebugHtmlReporter will be used by default.
Parameters:
Name | Type | Description |
---|---|---|
$formatter |
ezcDebugOutputFormatter |
startTimer
Starts the timer with the identifier $name.
Optionally, a timer group can be given with the $group parameter.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string | |
$group |
string |
stopTimer
Stops the timer identified by $name.
$name can be omitted (false) if only one timer is running.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string|bool |
switchTimer
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.
Parameters:
Name | Type | Description |
---|---|---|
$newName |
string | |
$oldName |
string|bool |