Example #1
0
 /**
  * The Autoloader initialisation
  *
  * @return void
  */
 public static function _init()
 {
     // is the profiler enabled?
     if (!(static::$_enabled = ClanCats::$config->get('profiler.enabled'))) {
         return;
     }
     // enable profiling only in development mode
     if (ClanCats::in_development()) {
         // add a hook to the resposne so that we can
         // append a table with the profiler data to the body
         CCEvent::mind('response.output', function ($output) {
             if (strpos($output, '</body>') === false) {
                 return $output;
             }
             $table = \UI\Table::create(array('style' => array('width' => '100%'), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-profiler'));
             $table->header(array('#', 'message', 'memory', 'time'));
             foreach (\CCProfiler::data() as $key => $item) {
                 $table->row(array($key + 1, $item[0], $item[1], $item[2]));
             }
             // add the table before the body end
             return str_replace('</body>', $table . "\n</body>", $output);
         });
         // also add an error inspector hook so that we can access the
         // profiler data in the error handler
         CCError_Inspector::info_callback('Profiler', function () {
             $table = array();
             foreach (\CCProfiler::data() as $key => $check) {
                 $table['#' . ($key + 1) . ': ' . $check[2]] = $check[0];
             }
             return $table;
         });
     }
 }
Example #2
0
 /**
  * Static init
  * When we are in development then we append the qurey log to body
  *
  * @codeCoverageIgnore
  *
  * @return void
  */
 public static function _init()
 {
     if (\ClanCats::in_development()) {
         // add a hook to the main resposne
         \CCEvent::mind('response.output', function ($output) {
             if (strpos($output, '</body>') === false) {
                 return $output;
             }
             $table = \UI\Table::create(array('style' => array('width' => '100%'), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-db'));
             $table->header(array('#', 'query'));
             foreach (static::log() as $key => $item) {
                 $table->row(array($key + 1, $item));
             }
             return str_replace('</body>', $table . "\n</body>", $output);
         });
     }
 }
Example #3
0
 /**
  * error class init
  *
  * @return void
  */
 public static function _init()
 {
     // we capture non fatal errors only in dev environments
     if (ClanCats::in_development()) {
         // add a hook to the main resposne
         CCEvent::mind('response.output', function ($output) {
             if (strpos($output, '</body>') === false) {
                 return $output;
             }
             $table = \UI\Table::create(array('style' => array('width' => '100%'), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-errors'));
             $table->header(array('#', 'message', 'file'));
             foreach (\CCError::$non_fatals as $key => $item) {
                 $table->row(array($key + 1, $item->getMessage(), CCStr::strip($item->getFile(), CCROOT) . ':' . $item->getLine()));
             }
             return str_replace('</body>', $table . "\n</body>", $output);
         });
     }
 }