From bc372e58312a801f223896eee7e3a3cfb8b94293 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 26 May 2024 17:50:37 +0200 Subject: [PATCH] Fix trace data not appearing in logfile in development mode --- ChangeLog.md | 1 + src/main/php/xp/web/WebRunner.class.php | 4 ++-- src/main/php/xp/web/dev/Console.class.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index d731ac22..2fddfe82 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ Web change log ## ?.?.? / ????-??-?? +* Fixed trace data not appearing in logfile in development mode - @thekid * Merged PR #115: Add `web.Headers::qfactors()`, which can be used when implementing content negotiation (@thekid) diff --git a/src/main/php/xp/web/WebRunner.class.php b/src/main/php/xp/web/WebRunner.class.php index e902cf3d..bac83f86 100755 --- a/src/main/php/xp/web/WebRunner.class.php +++ b/src/main/php/xp/web/WebRunner.class.php @@ -47,7 +47,7 @@ private static function error($request, $response, $env, $error) { break; } } - $env->logging()->log($request, $response, ['error' => $error]); + $env->logging()->log($request, $response, $response->trace + ['error' => $error]); } /** @@ -83,7 +83,7 @@ public static function main($args) { foreach ($application->service($request, $response) ?? [] as $event => $arg) { if ('delay' === $event) usleep($arg * 1000); } - $env->logging()->log($request, $response); + $env->logging()->log($request, $response, $response->trace); } catch (Error $e) { self::error($request, $response, $env, $e); } catch (Throwable $e) { diff --git a/src/main/php/xp/web/dev/Console.class.php b/src/main/php/xp/web/dev/Console.class.php index 1e7698ff..6af58813 100755 --- a/src/main/php/xp/web/dev/Console.class.php +++ b/src/main/php/xp/web/dev/Console.class.php @@ -54,6 +54,7 @@ public function filter($req, $res, $invocation) { $debug= ob_get_clean(); } + $res->trace= $buffer->trace; $out= $buffer->output(); if (empty($debug)) { $out->drain($res);