PHP Classes

Debug and measure actions: Log and render current script actions

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 192 All time: 8,541 This week: 119Up
Version License PHP version Categories
logrequest 1.0GNU Lesser Genera...5.0HTML, PHP 5, Logging, Performance and...


This class can log and render current script actions.

It can add messages to a log array about actions performed by each script. It keeps track of the action title, current time and importance level.

The class can display all the messages in a HTML page with the time that passed between actions, as well a summary with total elapsed time and the action that took longer.

Each action appears displayed using different CSS classes named after the action level.

Picture of Axel Hahn
  Performance   Level  
Name: Axel Hahn <contact>
Classes: 5 packages by
Country: Switzerland Switzerland
Age: 51
All time rank: 268126 in Switzerland Switzerland
Week rank: 332 Up2 in Switzerland Switzerland Up
Innovation award
Innovation award
Nominee: 2x


require '../classes/logger.class.php';
$oLog = new logger();
$bIsDevelopEnvironment = true;

$oLog->add("info ... all GET params: <pre>" . print_r($_GET,1) . "</pre>");
$oLog->add("info ... all POST params: <pre>" . print_r($_POST,1) . "</pre>");

$oLog->add("start db request");
$sSql='select id, label, description from mytable;';
// ... make your query
$oLog->add("sql query finished: " . $sSql);

$oLog->add("description of action");
// ... do something

$oLog->add("description of another action");
// ... do something else

if ($bIsDevelopEnvironment){



------------------------------------------------------------------------------- Debug logging during a client request. With this you can - measure any action - find bottlenecks in your code. Licence GPL 3.0 author: Axel Hahn ------------------------------------------------------------------------------- USAGE: (1) Trigger a message with add() to add a marker (2) The render() method lists all items in a table with time since start and the delta to the last message. An additional div on top right shows the execution time total and the time of the longest action (with a link to it). See the example.php. You don't need to write any print_r and var_dump anymore and remove it afterwards. Add _GET and _POST, and put a $oLog->add() at start and end of any action you want to measure. For production do not execute render method. Wrap it with a flag: if ($bIsDevelopEnvironment){ echo $oLog->render(); } If you init the logger globally you can put requests into your class example: /** * add a log messsage * @global object $oLog * @param string $sMessage messeage text * @param string $sLevel warnlevel of the given message * @return bool */ private function log($sMessage, $sLevel = "info") { global $oLog; if (!$oLog ||! is_object($oLog) || !method_exists($oLog, "add")){ return false; } return $oLog->add("class " . __CLASS__ . " - " . $sMessage, $sLevel); }

  • logger.png
  Files folder image Files  
File Role Description
Files folder imageclasses (1 file)
Files folder imageexample (1 file)
Accessible without login Plain text file readme.txt Doc. Readme

  Files folder image Files  /  classes  
File Role Description
  Plain text file logger.class.php Class logging class

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file example.php Example Example to mesaure your actions

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,541
This week:119Up