HSFirePHP! tries to queue all FirePHPCore logging statements and to rebuild them after page redirection which is used by Joomla! to execute tasks.
However some information - especially on trace - cannot be queued and thus not rebuild after page redirection either.
Use the object oriented API when you want to keep the logging statements in your application. It will provide more flexibility and future-proof your code.
FB:: *
Logging is enabled by default. You can disable it with setEnabled(false)
.
Use this method to disable logging on your live site for everyone except authorized users. The authorization is also handled by the HSFirePHP! plugin.
FB::setEnabled(false);
There is also an overloaded method equivalent to fb()
(see Procedural API) called FB::send()
.
FB::send(/* See fb() */);
The procedural API consists of one function. It is fast to type and the function arguments are overloaded.
fb($var); fb($var, 'Label'); fb($var, FirePHP::*); fb($var, 'Label', FirePHP::*);
Use the fb()
function for ad-hock debugging and development when you intend to remove the logging statements again.
The default values for the options can be set on the advanced tab of the HSFirePHP! plugin.
maxObjectDepth | Maximum depth to traverse objects. | |
maxArrayDepth | Maximum depth to traverse arrays. | |
maxDepth | Maximum depth to traverse mixed arrays/objects. | |
useNativeJsonEncode |
Set to FALSE to use JSON encoder included with FirePHPCore instead of json_encode() . |
|
includeLineNumbers | Include File and Line information in message. | |
lineNumberOffset | Offset of files in trace. |
// Defaults: $options = array(
'maxObjectDepth' => 5, 'maxArrayDepth' => 5, 'maxDepth' => 10, 'useNativeJsonEncode' => true, 'includeLineNumbers' => true,
'lineNumberOffset' => 0
); FB::setOptions($options);
To exclude specific members when logging objects use setObjectFilter()
.
FB::setObjectFilter('ClassName',
array('MemberName'));
Error, exception and assertion handling can be (de)activated on the advanced tab of the HSFirePHP! plugin.
Convert E_WARNING
, E_NOTICE
, E_USER_ERROR
, E_USER_WARNING
, E_USER_NOTICE
and E_RECOVERABLE_ERROR
errors to ErrorExceptions
and send all exceptions to the FirePHP extension automatically if desired.
Assertion errors can be converted to exceptions and thrown if desired.
You can also manually send caught exceptions to the FirePHP extension.
try { throw new Exception('Test Exception'); } catch (Exception $e) { FB::error($e); }
In many cases it is useful to group logging messages together. Groups can be nested programmatically and expanded/contracted by the user.
FB::group('Test Group'); FB::log('Hello World'); FB::groupEnd();
By default groups are expended in the FirePHP extension.
You can change the color of the group label by specifying a standard HTML color value.
FB::group(
'Colored Group',
array('Color' => '#FF0000')
);
These logging methods follow the four FirePHPCore logging priorities. Add an optional label as a second argument to any of these methods.
FB::log('Plain Message'); FB::info('Info Message'); FB::warn('Warn Message'); FB::error('Error Message');
FB::log('Message','Optional Label');
If you are using the fb()
function use the FirePHP::LOG
, FirePHP::INFO
, FirePHP::WARN
, FirePHP::ERROR
constants.
fb('Message', FirePHP::*);
You can log tables of information. The FirePHP extension will display the Table Label and allow the user to toggle the display of the table. The first row of the table is automatically used as the heading and the number of columns is dynamically determined.
$table = array(); $table[] = array('Col 1 Heading','Col 2 Heading'); $table[] = array('Row 1 Col 1','Row 1 Col 2'); $table[] = array('Row 2 Col 1','Row 2 Col 2'); $table[] = array('Row 3 Col 1','Row 3 Col 2'); FB::table('Table Label', $table);
If you are using the fb()
function use the FirePHP::TABLE
constant.
fb($table, 'Table Label', FirePHP::TABLE);
You can send a backtrace showing File, Line, Class, Method and Function information including Arguments to clearly show the execution path up to the point in your code where you triggered the trace.
FB::trace('Trace Label');
If you are using the fb()
function use the FirePHP::TRACE
constant.
fb('Trace Label', FirePHP::TRACE);
Source: FirePHPCore API Reference