2008-08-11 06:02:32 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A basic HTML wrapper for stylish rendering of a developement info view.
|
|
|
|
* Used to output error messages, and test results.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-08-11 06:02:32 +02:00
|
|
|
* @subpackage dev
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2008-08-11 06:02:32 +02:00
|
|
|
* @todo Perhaps DebugView should be an interface / ABC, implemented by HTMLDebugView and CliDebugView?
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CliDebugView extends DebugView {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render HTML header for development views
|
|
|
|
*/
|
2008-10-04 07:41:15 +02:00
|
|
|
public function writeHeader($httpRequest = null) {
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2008-08-11 06:02:32 +02:00
|
|
|
/**
|
|
|
|
* Render HTML footer for development views
|
|
|
|
*/
|
|
|
|
public function writeFooter() {
|
2014-08-15 08:53:05 +02:00
|
|
|
}
|
2008-08-11 06:02:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write information about the error to the screen
|
|
|
|
*/
|
|
|
|
public function writeError($httpRequest, $errno, $errstr, $errfile, $errline, $errcontext) {
|
2008-08-13 10:40:02 +02:00
|
|
|
$errorType = self::$error_types[$errno];
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
MINOR: Replaced usage of renamed classes with the new namespaced name.
From: Andrew Short <andrewjshort@gmail.com>
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90075 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-10-26 04:06:31 +01:00
|
|
|
echo SS_Cli::text("ERROR [" . $errorType['title'] . "]: $errstr\nIN $httpRequest\n", "red", null, true);
|
|
|
|
echo SS_Cli::text("Line $errline in $errfile\n\n", "red");
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a fragment of the a source file
|
|
|
|
* @param $lines An array of file lines; the keys should be the original line numbers
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function writeSourceFragment($lines, $errline) {
|
2008-08-11 06:02:32 +02:00
|
|
|
echo "Source\n======\n";
|
|
|
|
foreach($lines as $offset => $line) {
|
|
|
|
echo ($offset == $errline) ? "* " : " ";
|
|
|
|
echo str_pad("$offset:",5);
|
2014-07-05 04:37:06 +02:00
|
|
|
echo wordwrap($line, self::config()->columns, "\n ");
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
|
|
|
echo "\n";
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2008-08-11 06:02:32 +02:00
|
|
|
/**
|
|
|
|
* Write a backtrace
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function writeTrace($trace = null) {
|
2010-04-12 05:36:27 +02:00
|
|
|
echo "Trace\n=====\n";
|
|
|
|
echo SS_Backtrace::get_rendered_backtrace($trace ? $trace : debug_backtrace(), true);
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
2008-08-13 03:47:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the information header for the view
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2008-08-13 03:47:05 +02:00
|
|
|
* @param string $title
|
|
|
|
* @param string $title
|
|
|
|
*/
|
|
|
|
public function writeInfo($title, $subtitle, $description=false) {
|
2014-07-05 04:37:06 +02:00
|
|
|
echo wordwrap(strtoupper($title),self::config()->columns) . "\n";
|
|
|
|
echo wordwrap($subtitle,self::config()->columns) . "\n";
|
|
|
|
echo str_repeat('-',min(self::config()->columns,max(strlen($title),strlen($subtitle)))) . "\n";
|
|
|
|
echo wordwrap($description,self::config()->columns) . "\n\n";
|
2008-08-13 03:47:05 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2014-07-05 04:37:06 +02:00
|
|
|
public function writeVariable($val, $caller) {
|
|
|
|
echo PHP_EOL;
|
|
|
|
echo SS_Cli::text(str_repeat('=', self::config()->columns), 'green');
|
|
|
|
echo PHP_EOL;
|
|
|
|
echo SS_Cli::text($this->formatCaller($caller), 'blue', null, true);
|
|
|
|
echo PHP_EOL.PHP_EOL;
|
|
|
|
if (is_string($val)) {
|
|
|
|
print_r(wordwrap($val, self::config()->columns));
|
|
|
|
} else {
|
|
|
|
print_r($val);
|
|
|
|
}
|
|
|
|
echo PHP_EOL;
|
|
|
|
echo SS_Cli::text(str_repeat('=', self::config()->columns), 'green');
|
|
|
|
echo PHP_EOL;
|
|
|
|
}
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|