Skip to content

Commit

Permalink
Added better log viewing (#1303)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Towers <[email protected]>
Related: wintercms/storm#204

This adds a fully backwards compatible "v2" log viewer that allows of unrolling of all previous exceptions. It also adds snippets for each frame in the call stack and extra information about the environment is recorded and displayed to the user.

This is a stopgap solution until we get around to fully implementing the Ignition error page in Winter CMS core and displaying stored errors with that instead.
  • Loading branch information
jaxwilko authored Feb 13, 2025
1 parent bcd8aa7 commit 7951a22
Show file tree
Hide file tree
Showing 5 changed files with 534 additions and 19 deletions.
17 changes: 6 additions & 11 deletions modules/cms/classes/CodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,16 @@ protected function rebuild($path)
$fileContents .= trim($body).PHP_EOL;
$fileContents .= '}'.PHP_EOL;

$this->validate($fileContents);

$this->makeDirectorySafe(dirname($path));

$this->writeContentSafe($path, $fileContents);

// Attempt to load the generated code file to ensure any errors are thrown
// before the file is cached
if (!class_exists($className)) {
require_once $path;
}

return $className;
}

Expand Down Expand Up @@ -289,15 +293,6 @@ protected function getCachedFileInfo()
// Helpers
//

/**
* Evaluates PHP content in order to detect syntax errors.
* The method handles PHP errors and throws exceptions.
*/
protected function validate($php)
{
eval('?>'.$php);
}

/**
* Extracts the class name from a cache file
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
var ExceptionBeautifier = $.fn.exceptionBeautifier.Constructor

ExceptionBeautifier.EDITORS = {
vscode: {scheme: 'vscode://file/%file:%line', name: 'VS Code (vscode://)'},
phpstorm: {scheme: 'phpstorm://open?file=%file&line=%line', name: 'PhpStorm (phpstorm://)'},
subl: {scheme: 'subl://open?url=file://%file&line=%line', name: 'Sublime (subl://)'},
txmt: {scheme: 'txmt://open/?url=file://%file&line=%line', name: 'TextMate (txmt://)'},
mvim: {scheme: 'mvim://open/?url=file://%file&line=%line', name: 'MacVim (mvim://)'},
phpstorm: {scheme: 'phpstorm://open?file=%file&line=%line', name: 'PhpStorm (phpstorm://)'},
editor: {scheme: 'editor://open/?file=%file&line=%line', name: 'Custom (editor://)'}
}

Expand Down
Loading

0 comments on commit 7951a22

Please sign in to comment.