Browse Source

updated Debug

Piotr Labudda 8 years ago
parent
commit
8efad21124
2 changed files with 29 additions and 16 deletions
  1. 7 2
      SE/se-lib/DBG.php
  2. 22 14
      SE/se-lib/Route/Debug.php

+ 7 - 2
SE/se-lib/DBG.php

@@ -337,6 +337,10 @@ class DBG {
 		if (!empty($logInfo['trace'])) {
 			$trace = array_map(function ($part) {
 				if ('URI: ' === substr($part, 0, strlen('URI: '))) return "#{$part}";
+				if ($pos = strpos($part, '{closure}')) {
+					// #10 Route_Storage_AclStruct->{closure}(Array ([namespace] => default_db/BI_audit_ENERGA_PRAC ... )
+					return "#" . substr($part, 0, 200) . ( strlen($part) > 200 ? '...' : '' );
+				}
 				if ($pos = strrpos($part, ' called at [')) {
 					$spacePos = strpos($part, ' ');
 					$spacePos = (' ' === $part[$spacePos + 1]) ? $spacePos + 1 : $spacePos;
@@ -344,11 +348,12 @@ class DBG {
 					$spacePos += 1;
 					$called = substr($part, $pos + strlen(' called at ['), -1);
 					$nr = substr($part, 0, $spacePos);
-					$line = substr($part, $spacePos, ($pos > 300) ? 300 : $pos - $spacePos);
+					$line = substr($part, $spacePos, ($pos > 200) ? 200 : $pos - $spacePos);
+					if ($pos > 200) $line .= "...";
 					$line = str_replace("\n", '\\n', $line);
 					return "#{$nr}{$called}: {$line}";
 				}
-				return $part;
+				return "#" . substr($part, 0, 200) . ( strlen($part) > 200 ? '...' : '' );
 			}, explode("\n#", $logInfo['trace']));
 			array_shift($trace);
 			$logInfo['trace'] = implode("\n", $trace);

+ 22 - 14
SE/se-lib/Route/Debug.php

@@ -397,7 +397,7 @@ class Route_Debug extends RouteBase {
 		$logPath = "{$this->logPathPrefix}se-{$type}-{$logName}.log";
 		if (!file_exists($logPath)) throw new Exception("Log file not exists");
 		$content = file_get_contents($logPath);
-	$lastTime = '';
+		$lastTime = '';
 		UI::table([
 			'cols' => [
 				'date',
@@ -420,11 +420,15 @@ class Route_Debug extends RouteBase {
 							'msg' => "Error Processing Request - Parse json error: " . json_last_error()
 						];
 					}
-			$timeDiff = (!$lastTime)
-				? ''
-			: V::milisecondsStringDiff($dbg['date'], $lastTime)
-			; // TODO: $dbg['date'] - $lastTime;
-			$lastTime = $dbg['date'];
+					$timeDiff = (!$lastTime)
+					? ''
+					: V::milisecondsStringDiff($dbg['date'], $lastTime); // TODO: $dbg['date'] - $lastTime;
+					$lastTime = $dbg['date'];
+					$trace = htmlspecialchars($dbg['trace']);
+					$trace = str_replace("\n", "\n<br>", $trace);
+					if ('#' === substr($trace, 0, 1)) $trace = "<br>{$trace}";
+					$trace = preg_replace('/<br>#(\d+\W+)([a-zA-Z0-9-_:\.\/]*):/', '#${1}<a href="http://localhost:9876/?project=se&file=${2}" target="_blank">${2}</a>:', $trace);
+					$trace = str_replace("\n<br>", "\n", $trace);
 					return [
 						'date' => '<nobr>' . $dbg['date'] . '</nobr>',
 						'diff' => '<nobr>' . $timeDiff . '</nobr>',
@@ -442,14 +446,18 @@ class Route_Debug extends RouteBase {
 							], str_replace(array('\n', '\t'), ' ', substr(htmlspecialchars(json_encode($dbg['log'])), 0, 100)) . ' ...')
 						]),
 						'trace' => UI::h('div', [], [
-							UI::h('div', [
-								'title' => htmlspecialchars($dbg['trace']),
-								'onClick' => "return p5DBG__showLogTrace(this, event)",
-								'style' => "cursor:pointer"
-							], ('Exception' == $dbg['type'])
-								? "Code: {$dbg['log']['code']}, File: {$dbg['log']['file']}"
-								: '...'
-							)
+							UI::h('details', [], [
+								UI::h('summary', [], "trace: (rozwiń)"),
+								UI::h('pre', [ 'style' => "font-size:x-small" ], $trace),
+								UI::h('div', [
+									'title' => htmlspecialchars($dbg['trace']),
+									'onClick' => "return p5DBG__showLogTrace(this, event)",
+									'style' => "cursor:pointer"
+								], ('Exception' == $dbg['type'])
+									? "Code: {$dbg['log']['code']}, File: {$dbg['log']['file']}"
+									: '...'
+								),
+							]),
 						]),
 					];
 				},