Skip to content

Commit 65b6a23

Browse files
committed
Add trace marker when development console is shown
1 parent 7e96f0c commit 65b6a23

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Web change log
55

66
## 4.4.0 / 2024-06-10
77

8+
* Added trace marker (*debug* or *error*) to the server log files when
9+
the development console is shown.
10+
(@thekid)
811
* Merged PR #117: Catch errors and display them in development console.
912
(@thekid)
1013
* Fixed `echo 0;` (or 0.0, or "0") not triggering the development console

src/main/php/xp/web/dev/Console.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ public function filter($req, $res, $invocation) {
5252
try {
5353
ob_start();
5454
yield from $invocation->proceed($req, $buffer);
55+
$status= 200;
5556
$kind= 'debug';
5657
$debug= ob_get_clean();
5758
} catch (Throwable $t) {
59+
$buffer->answer($status= $t instanceof Error ? $t->status() : 500);
5860
$kind= 'error';
59-
$buffer->answer($t instanceof Error ? $t->status() : 500);
6061
$debug= ob_get_clean()."\n".XPException::wrap($t)->toString();
6162
} finally {
6263
$buffer->end();
@@ -67,7 +68,8 @@ public function filter($req, $res, $invocation) {
6768
if (0 === strlen($debug)) {
6869
$out->drain($res);
6970
} else {
70-
$res->status(200, 'Debug');
71+
$res->trace+= ['console' => $kind];
72+
$res->answer($status, $kind);
7173
$res->send($this->transform(typeof($this)->getClassLoader()->getResource($this->template), [
7274
'kind' => $kind,
7375
'debug' => $debug,

0 commit comments

Comments
 (0)