Posts Tagged ‘tool’

Profiling and DB Profiling with DooPHP

If you have read the previous tutorial on logging you will find that profiling with DooPHP framework is relatively similar to the way you log messages.

Performance profiling can be used to measure the time & memory needed for the specified code blocks and find out what the performance bottleneck is. Instead of calling log() you change it to beginProfile() and endProfile(). We need to mark the beginning and the end of each code block by inserting the following methods:

Doo::logger()->beginProfile('block_id_here');
//...everything here will be profiled
Doo::logger()->endProfile('block_id_here');

Code blocks need to be nested properly. A code block cannot intersect with another. It must be either at a parallel level or be completely enclosed by the other code block.

All of the profiled results can be organized in category, simply pass in another parameter at the end of the method beginProfile():

//default category is 'application'
Doo::logger()->beginProfile('id', 'editpost');
//...everything here will be profiled
Doo::logger()->endProfile('id');

To retrieve the profiled results, you called getProfileResult(). You have to pass in the block ID as parameter and you will get an associative array which shows you the time and memory used when processing the code block.

Doo::logger()->beginProfile('block_id');
//...everything here will be profiled
Doo::logger()->endProfile('block_id');
$result = Doo::logger()->getProfileResult('block_id');

To view the profiled results, you just have to call showLogs(). By default it will return a neatly

More »

Using DooPHP Logging Tools

DooPHP comes with its own profiler and logging tool by default. The class that handle this in the framework is DooLog (dooframework/app/logging/DooLog.php)

There are a few methods in this file where you can use for profiling and logging queries or important message in your application. You can log a message by calling:

Doo::logger()->log('Something fishy here!', DooLog::Alert);

Or you can use the Alias methods instead of passing the log level:

Doo::logger()->alert('Something fishy here!');
Doo::logger()->emerg('message...');
Doo::logger()->crit('message...');
Doo::logger()->err('message...');
Doo::logger()->warn('message...');
Doo::logger()->notice('message...');
Doo::logger()->info('message...');
Doo::logger()->trace('message...');

All of the log messages can be organized by category, simply pass in another parameter at the end of the methods:

Doo::logger()->log('Something fishy here!', DooLog::ALERT, 'editpost');
Doo::logger()->emerg('message...', 'editpost');
Doo::logger()->alert('message...', 'editpost');

To view the logged messages, you just have to call showLogs(). By default DooLog will return a neatly formatted XML log which can be filtered by level or category. You can get a plain text log if you need so:

//display all logs
echo Doo::logger()->showLogs();

//display plain text log
echo Doo::logger()->showLogs(false);

//display only logs in category editpost
echo Doo::logger()->showLogs(true, null, 'editpost');

//display only logs in level Alert and category editpost
echo Doo::logger()->showLogs(true, DooLog::ALERT, 'editpost');

When you have to write the log messages into file, all you have to do is call writeLogs(). Similar to showLogs(), it writes the XML string to file by default.


//Creates a log file
More »

DooPHP Sitemap Generator Tool Demo

This is a demo showing you how to use DooPHP sitemap generator tools to generate routes as well as Controller classes.

DooPHP Sitemap Generator tool

More »