Skip to content

Commit 70691b2

Browse files
committed
Keep message format keys for nicer middleware names
1 parent 52f27ed commit 70691b2

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/Mixins/PendingRequestMixin.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@ public function log()
2222
return $this;
2323
}
2424

25-
$messageFormats = array_values(
26-
config('http-client-global-logger.format')
27-
);
28-
2925
$stack = $this->buildHandlerStack();
3026

3127
/** @var Logger $logger */
3228
$logger = Log::channel(config('http-client-global-logger.channel'));
3329
if (! is_null($name)) {
3430
$logger = $logger->withName($name);
3531
}
36-
foreach ($messageFormats as $key => $format) {
32+
33+
foreach (config('http-client-global-logger.format') as $key => $format) {
3734
// We'll use unshift instead of push, to add the middleware to the bottom of the stack, not the top
3835
$stack->unshift(
3936
Middleware::log($logger, new MessageFormatter($format)),

tests/PendingRequestMixinTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
// We need to invade the HandlerStack to access the stack property or findByName method
1818
expect($handler)->toBeInstanceOf(HandlerStack::class)
19-
->and(invade($handler)->findByName('http-client-global-logger-0'))->toBeInt()
20-
->and(invade($handler)->findByName('http-client-global-logger-1'))->toBeInt()
21-
->and(fn () => invade($handler)->findByName('http-client-global-logger-2'))
19+
->and(invade($handler)->findByName('http-client-global-logger-request'))->toBeInt()
20+
->and(invade($handler)->findByName('http-client-global-logger-response'))->toBeInt()
21+
->and(fn () => invade($handler)->findByName('http-client-global-logger-0'))
2222
->toThrow(\InvalidArgumentException::class);
2323
});

0 commit comments

Comments
 (0)