public static function cliError($title, $exception) { $trace_elements = null; if ($exception instanceof \Exception) { if ($exception instanceof \thebuggenie\core\framework\exceptions\ActionNotFoundException) { self::cli_echo("Could not find the specified action\n", 'white', 'bold'); } elseif ($exception instanceof \thebuggenie\core\framework\exceptions\TemplateNotFoundException) { self::cli_echo("Could not find the template file for the specified action\n", 'white', 'bold'); } elseif ($exception instanceof \b2db\Exception) { self::cli_echo("An exception was thrown in the B2DB framework\n", 'white', 'bold'); } else { self::cli_echo("An unhandled exception occurred:\n", 'white', 'bold'); } echo self::cli_echo($exception->getMessage(), 'red', 'bold') . "\n"; echo "\n"; self::cli_echo('Stack trace') . ":\n"; $trace_elements = $exception->getTrace(); } else { if ($exception['code'] == 8) { self::cli_echo('The following notice has stopped further execution:', 'white', 'bold'); } else { self::cli_echo('The following error occured:', 'white', 'bold'); } echo "\n"; echo "\n"; self::cli_echo($title, 'red', 'bold'); echo "\n"; self::cli_echo("occured in\n"); self::cli_echo($exception['file'] . ', line ' . $exception['line'], 'blue', 'bold'); echo "\n"; echo "\n"; self::cli_echo("Backtrace:\n", 'white', 'bold'); $trace_elements = debug_backtrace(); } foreach ($trace_elements as $trace_element) { if (array_key_exists('class', $trace_element)) { if (array_key_exists('class', $trace_element) && $trace_element['class'] == 'thebuggenie\\core\\framework\\Context' && array_key_exists('function', $trace_element) && in_array($trace_element['function'], array('errorHandler', 'cliError'))) { continue; } self::cli_echo($trace_element['class'] . $trace_element['type'] . $trace_element['function'] . '()'); } elseif (array_key_exists('function', $trace_element)) { self::cli_echo($trace_element['function'] . '()'); } else { self::cli_echo('unknown function'); } echo "\n"; if (array_key_exists('file', $trace_element)) { self::cli_echo($trace_element['file'] . ', line ' . $trace_element['line'], 'blue', 'bold'); } else { self::cli_echo('unknown file', 'red', 'bold'); } echo "\n"; } if (class_exists('\\b2db\\Core')) { echo "\n"; $sqlhits = \b2db\Core::getSQLHits(); if (count($sqlhits)) { self::cli_echo("SQL queries:\n", 'white', 'bold'); try { $cc = 1; foreach ($sqlhits as $details) { self::cli_echo("(" . $cc++ . ") ["); $str = $details['time'] >= 1 ? round($details['time'], 2) . ' seconds' : round($details['time'] * 1000, 1) . 'ms'; self::cli_echo($str); self::cli_echo("] from "); self::cli_echo($details['filename'], 'blue'); self::cli_echo(", line "); self::cli_echo($details['line'], 'white', 'bold'); self::cli_echo(":\n"); self::cli_echo("{$details['sql']}\n"); } echo "\n"; } catch (\Exception $e) { self::cli_echo("Could not generate query list (there may be no database connection)", "red", "bold"); } } } echo "\n"; }
<?php // prepare fields $dbgjson = $csp_debugger->getJsonOutput(); $dbgstored = $csp_debugger->getStoredVariables(); $dbglog = \caspar\core\Logging::getEntries(); $dbgpartials = $csp_debugger->getPartials(); if (\b2db\Core::isConnected()) { $dbgqueries = \b2db\Core::getSQLHits(); $dbgquerytime = \b2db\Core::getSQLTiming(); $dbgquerycount = \b2db\Core::getSQLCount(); } ?> <div class="csp-dbg-entry-row" id="csp-dbg-row-<?php echo $cspdbgrow; ?> "> <?php if ($csp_debugger->isAjaxRequest()) { ?> AJAX Request<?php } else { ?> This page<?php } ?> - <?php echo $csp_debugger->getRouting()->getCurrentRouteName(); ?> <span class="csp-dbg-entry-timestamp">
protected static function generateDebugInfo() { $tbg_summary = array(); $load_time = self::getLoadtime(); if (\b2db\Core::isInitialized()) { $tbg_summary['db']['queries'] = \b2db\Core::getSQLHits(); $tbg_summary['db']['timing'] = \b2db\Core::getSQLTiming(); $tbg_summary['db']['objectpopulation'] = \b2db\Core::getObjectPopulationHits(); $tbg_summary['db']['objecttiming'] = \b2db\Core::getObjectPopulationTiming(); $tbg_summary['db']['objectcount'] = \b2db\Core::getObjectPopulationCount(); } $tbg_summary['load_time'] = $load_time >= 1 ? round($load_time, 2) . 's' : round($load_time * 1000, 1) . 'ms'; $tbg_summary['scope'] = array(); $scope = self::getScope(); $tbg_summary['scope']['id'] = $scope instanceof Scope ? $scope->getID() : 'unknown'; $tbg_summary['scope']['hostnames'] = $scope instanceof Scope && \b2db\Core::isConnected() ? implode(', ', $scope->getHostnames()) : 'unknown'; $tbg_summary['settings'] = Settings::getAll(); $tbg_summary['memory'] = memory_get_usage(); $tbg_summary['partials'] = self::getVisitedPartials(); $tbg_summary['log'] = Logging::getEntries(); $tbg_summary['routing'] = array('name' => self::getRouting()->getCurrentRouteName(), 'module' => self::getRouting()->getCurrentRouteModule(), 'action' => self::getRouting()->getCurrentRouteAction()); if (isset($_SESSION)) { if (!array_key_exists('___DEBUGINFO___', $_SESSION)) { $_SESSION['___DEBUGINFO___'] = array(); } $_SESSION['___DEBUGINFO___'][self::$debug_id] = $tbg_summary; while (count($_SESSION['___DEBUGINFO___']) > 25) { array_shift($_SESSION['___DEBUGINFO___']); } } }
echo $entry['message']; ?> </div> <?php } ?> <?php } ?> <?php if (class_exists("\\b2db\\Core") && TBGContext::isDebugMode() && (!isset($exception) || !$exception instanceof TBGComposerException)) { ?> <h3>SQL queries:</h3> <ol> <?php foreach (\b2db\Core::getSQLHits() as $details) { ?> <li> <span class="faded_out dark small"><b>[<?php echo $details['time'] >= 1 ? round($details['time'], 2) . ' seconds' : round($details['time'] * 1000, 1) . 'ms'; ?> ]</b></span> from <b><?php echo $details['filename']; ?> , line <?php echo $details['line']; ?> </b>:<br> <span style="font-size: 12px;"><?php echo $details['sql'];
protected static function generateDebugInfo() { $tbg_summary = array(); $load_time = self::getLoadtime(); if (\b2db\Core::isInitialized()) { $tbg_summary['db']['queries'] = \b2db\Core::getSQLHits(); $tbg_summary['db']['timing'] = \b2db\Core::getSQLTiming(); } $tbg_summary['load_time'] = $load_time >= 1 ? round($load_time, 2) . 's' : round($load_time * 1000, 1) . 'ms'; $tbg_summary['scope'] = array(); $scope = self::getScope(); $tbg_summary['scope']['id'] = $scope instanceof TBGScope ? $scope->getID() : 'unknown'; $tbg_summary['scope']['hostnames'] = $scope instanceof TBGScope && \b2db\Core::isConnected() ? implode(', ', $scope->getHostnames()) : 'unknown'; $tbg_summary['settings'] = TBGSettings::getAll(); $tbg_summary['memory'] = memory_get_usage(); $tbg_summary['partials'] = self::getVisitedPartials(); if (self::$_i18n instanceof TBGI18n) { foreach (self::getI18n()->getMissingStrings() as $text => $value) { TBGLogging::log('The text "' . $text . '" does not exist in list of translated strings, and was added automatically', 'i18n', TBGLogging::LEVEL_NOTICE); } } $tbg_summary['log'] = TBGLogging::getEntries(); $tbg_summary['routing'] = array('name' => self::getRouting()->getCurrentRouteName(), 'module' => self::getRouting()->getCurrentRouteModule(), 'action' => self::getRouting()->getCurrentRouteAction()); if (isset($_SESSION)) { if (!array_key_exists('___DEBUGINFO___', $_SESSION)) { $_SESSION['___DEBUGINFO___'] = array(); } $_SESSION['___DEBUGINFO___'][self::$debug_id] = $tbg_summary; while (count($_SESSION['___DEBUGINFO___']) > 10) { array_shift($_SESSION['___DEBUGINFO___']); } } }