Skip to content

Commit

Permalink
chore(testCommand): optimize exception notify client configuration
Browse files Browse the repository at this point in the history
- Optimize exception notify client configuration in TestCommand.php
- Added middleware to dump response before logging
  • Loading branch information
guanguans committed May 11, 2024
1 parent ee54798 commit 9680a2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ parameters:
count: 1
path: src/Commands/TestCommand.php

-
message: "#^Call to method push\\(\\) on an unknown class Guanguans\\\\Notify\\\\Foundation\\\\Concerns\\\\HasHttpClient\\.$#"
count: 1
path: src/Commands/TestCommand.php

-
message: "#^Method Guanguans\\\\LaravelExceptionNotify\\\\Rectors\\\\ToInternalExceptionRector\\:\\:refactor\\(\\) should return 1\\|2\\|3\\|4\\|array\\<PhpParser\\\\Node\\>\\|PhpParser\\\\Node\\|null but empty return statement found\\.$#"
count: 1
Expand Down
3 changes: 0 additions & 3 deletions src/Collectors/RequestHeaderCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function __construct(Request $request)
$this->request = $request;
}

/**
* @noinspection PhpUndefinedMethodInspection
*/
public function collect(): array
{
return collect($this->request->header())
Expand Down
10 changes: 7 additions & 3 deletions src/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Guanguans\LaravelExceptionNotify\ExceptionNotifyManager;
use Guanguans\LaravelExceptionNotify\Exceptions\RuntimeException;
use Guanguans\Notify\Foundation\Client;
use Guanguans\Notify\Foundation\Response;
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Middleware;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -92,9 +93,12 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
if ('notify' === $config['driver']) {
config()->set(
"exception-notify.channels.$name.client.extender",
static fn (Client $client): Client => $client->push(
Middleware::log(Log::channel(), new MessageFormatter(MessageFormatter::DEBUG), 'debug'),
)
static fn (Client $client): Client => $client
->before(
\Guanguans\Notify\Foundation\Middleware\Response::class,
Middleware::mapResponse(static fn (Response $response): Response => $response->dump()),
)
->push(Middleware::log(Log::channel(), new MessageFormatter(MessageFormatter::DEBUG), 'debug'))
);
}
});
Expand Down

0 comments on commit 9680a2e

Please sign in to comment.