From 6100d2521868953e903e288c4c2f53ae3e0b0cb5 Mon Sep 17 00:00:00 2001 From: Frugan Date: Fri, 5 Sep 2025 22:10:39 +0200 Subject: [PATCH] fix: wonolog v2.x/v3.x PSR-3 placeholder substitution compatibility HookLogFactory::fromString() wraps context as $arguments = [0 => $context], breaking PsrLogMessageProcessor placeholders like {handle} and {url} --- src/Logger.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Logger.php b/src/Logger.php index 5a1ccf9..f7f3e92 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -540,7 +540,19 @@ private function logViaWonolog(string $level, mixed $message, array $context): v } if (\function_exists('do_action')) { - do_action($actionName, $message, $context); + // BUGFIX: Wonolog v2.x/v3.x PSR-3 placeholder substitution compatibility + // + // HookLogFactory::fromString() wraps context as $arguments = [0 => $context], + // breaking PsrLogMessageProcessor placeholders like {handle} and {url}. + // + // Using array format forces fromArray() method which preserves correct + // context structure. This works with all current Wonolog versions and + // has no negative side effects. + $logData = [ + 'message' => $message, + 'context' => $context, + ]; + do_action($actionName, $logData); } }