Commit 2e14e490 authored by Tomáš Pospíšil's avatar Tomáš Pospíšil
Browse files

error parsing improvements

parent eb3c1055
......@@ -330,22 +330,22 @@
},
{
"name": "voku/html-min",
"version": "4.3.0",
"version": "4.4.3",
"source": {
"type": "git",
"url": "https://github.com/voku/HtmlMin.git",
"reference": "fa912ebd0c2c338868af2e8a14436f5ad1af6e83"
"reference": "5f7938bb739a64582bcaf413b23b6a2f16defee9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/voku/HtmlMin/zipball/fa912ebd0c2c338868af2e8a14436f5ad1af6e83",
"reference": "fa912ebd0c2c338868af2e8a14436f5ad1af6e83",
"url": "https://api.github.com/repos/voku/HtmlMin/zipball/5f7938bb739a64582bcaf413b23b6a2f16defee9",
"reference": "5f7938bb739a64582bcaf413b23b6a2f16defee9",
"shasum": ""
},
"require": {
"ext-dom": "*",
"php": ">=7.0.0",
"voku/simple_html_dom": "~4.7.13"
"voku/simple_html_dom": "~4.7.16"
},
"require-dev": {
"phpunit/phpunit": "~6.0 || ~7.0"
......@@ -389,20 +389,20 @@
"type": "patreon"
}
],
"time": "2020-03-22T22:20:41+00:00"
"time": "2020-04-06T21:26:16+00:00"
},
{
"name": "voku/simple_html_dom",
"version": "4.7.14",
"version": "4.7.16",
"source": {
"type": "git",
"url": "https://github.com/voku/simple_html_dom.git",
"reference": "eed633604e7fec922a4af5ccd306762ef4a2bdac"
"reference": "dc51b4c2702ffd83a16b343137cd4a570b713cbd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/voku/simple_html_dom/zipball/eed633604e7fec922a4af5ccd306762ef4a2bdac",
"reference": "eed633604e7fec922a4af5ccd306762ef4a2bdac",
"url": "https://api.github.com/repos/voku/simple_html_dom/zipball/dc51b4c2702ffd83a16b343137cd4a570b713cbd",
"reference": "dc51b4c2702ffd83a16b343137cd4a570b713cbd",
"shasum": ""
},
"require": {
......@@ -466,7 +466,7 @@
"type": "tidelift"
}
],
"time": "2020-04-02T00:34:59+00:00"
"time": "2020-04-05T21:42:33+00:00"
}
],
"packages-dev": [
......
......@@ -7,6 +7,7 @@ namespace Praguebest\BarPanel;
use Praguebest\Tools\ErrorFilesParser;
use Smarty;
use SmartyException;
use Tracy\ILogger;
final class ErrorCountBar extends BaseBarPanel
{
......@@ -32,6 +33,18 @@ final class ErrorCountBar extends BaseBarPanel
$this->smarty->assign('criticals', $parser->countCriticals($errors));
$this->smarty->assign('warnings', $parser->countWarnings($errors));
$this->smarty->assign('infos', $parser->countInfos($errors));
$this->smarty->assign(
'typeColor',
[
ILogger::CRITICAL => 'red',
ILogger::EXCEPTION => 'red',
ILogger::ERROR => 'red',
ErrorFilesParser::UNKNOWN => 'red',
ILogger::WARNING => 'yellow',
ILogger::DEBUG => 'lighskyblue',
ILogger::INFO => 'lighskyblue',
]
);
}
/**
......
......@@ -111,6 +111,7 @@ final class Registrator
Debugger::$strictMode = $currentSetting->isOn();
Debugger::$maxLength = 512;
Debugger::$maxDepth = 5;
Debugger::$logSeverity = E_ALL;
Debugger::enable('42@84.42.168.182,42@185.156.123.46,42@178.77.200.253', realpath($errorDir), Strings::replace($emailDeveloper, '/,;/', ','));
$this->addPanel(
......
......@@ -94,10 +94,7 @@ final class Dumper
public static function editorLink(string $file, int $line = null): string
{
self::$projectPath = self::$projectPath ?? PersistentValue::getCurrentValue(self::PROJECT_PATH);
if (self::$projectPath) {
$file = Strings::replace($file, '#' . preg_quote(self::getDirectory(), '#') . '#', self::$projectPath);
}
$file = self::localizePath($file);
$file = strtr($origFile = $file, Debugger::$editorMapping);
if ($editor = self::editorUri($origFile, $line)) {
......@@ -205,4 +202,24 @@ final class Dumper
{
return ['Skipped'];
}
/**
* @param string $file
* @return string
*/
private static function localizePath(string $file): string
{
self::$projectPath = self::$projectPath ?? PersistentValue::getCurrentValue(self::PROJECT_PATH);
if (!self::$projectPath) {
return $file;
}
$byLocalDirectory = Strings::replace($file, '#' . preg_quote(self::getDirectory(), '#') . '#', self::$projectPath);
if ($byLocalDirectory === $file) {
return Strings::replace($file, '#(?<serverPath>.*?\.(\w+)\/)#', self::$projectPath);
}
return $byLocalDirectory;
}
}
......@@ -56,7 +56,7 @@ final class ErrorFilesParser
[
'time' => filectime($filename) ?? 0,
'type' => $type,
'filename' => basename($filename),
'filename' => $this->getFilelink($filename),
'message' => Strings::truncate($message['message'] ?? '', 200),
'link' => Dumper::editorLink($message['location'] ?? '', (int)$message['row']),
]
......@@ -115,11 +115,14 @@ final class ErrorFilesParser
*/
private function countErrorsByType(ArrayObject $errors, array $types): int
{
return count(array_filter($errors->getArrayCopy(),
static function ($error) use ($types) {
return in_array($error['type'], $types, true);
}
));
return count(
array_filter(
$errors->getArrayCopy(),
static function ($error) use ($types) {
return in_array($error['type'], $types, true);
}
)
);
}
public function countWarnings(ArrayObject $errors): int
......@@ -131,4 +134,15 @@ final class ErrorFilesParser
{
return $this->countErrorsByType($errors, [ILogger::DEBUG, ILogger::INFO]);
}
/**
* @param string $filename
* @return string
*/
private function getFilelink(string $filename): string
{
$link = "<a href='file://%s'>%s</a>";
return sprintf($link, rawurlencode($filename), basename($filename));
}
}
......@@ -7,15 +7,8 @@
<tr>
<td>
<div>
<strong style="width: 50px; color: white;">
{if in_array($error.type, ['critical','exception','error','unknown'])}
<strong style="background-color: red; padding: 0 5px;">{$error.type}</strong>
{elseif $error.type==='warning'}
<strong style="background-color: yellow; padding: 0 5px;">{$error.type}</strong>
{else}
<strong style="background-color: lightskyblue; padding: 0 5px;"> {$error.type}</strong>
{/if}
</strong><strong>{$error.message}</strong>
<strong style="width: 50px; color: white;background-color: {$typeColor[$error.type]}; padding: 0 5px; margin-right:5px; ">{$error.type}</strong>
<strong>{$error.message}</strong>
</div>
<div>
<small>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment