Skip to content

Commit

Permalink
Add trace marker when development console is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jun 10, 2024
1 parent 7e96f0c commit 65b6a23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Web change log

## 4.4.0 / 2024-06-10

* Added trace marker (*debug* or *error*) to the server log files when
the development console is shown.
(@thekid)
* Merged PR #117: Catch errors and display them in development console.
(@thekid)
* Fixed `echo 0;` (or 0.0, or "0") not triggering the development console
Expand Down
6 changes: 4 additions & 2 deletions src/main/php/xp/web/dev/Console.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ public function filter($req, $res, $invocation) {
try {
ob_start();
yield from $invocation->proceed($req, $buffer);
$status= 200;
$kind= 'debug';
$debug= ob_get_clean();
} catch (Throwable $t) {
$buffer->answer($status= $t instanceof Error ? $t->status() : 500);
$kind= 'error';
$buffer->answer($t instanceof Error ? $t->status() : 500);
$debug= ob_get_clean()."\n".XPException::wrap($t)->toString();
} finally {
$buffer->end();
Expand All @@ -67,7 +68,8 @@ public function filter($req, $res, $invocation) {
if (0 === strlen($debug)) {
$out->drain($res);
} else {
$res->status(200, 'Debug');
$res->trace+= ['console' => $kind];
$res->answer($status, $kind);
$res->send($this->transform(typeof($this)->getClassLoader()->getResource($this->template), [
'kind' => $kind,
'debug' => $debug,
Expand Down

0 comments on commit 65b6a23

Please sign in to comment.