Skip to content

Commit 3101825

Browse files
committed
add app_name, path, and httpCode
1 parent 3515569 commit 3101825

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Libraries/ClientExternal.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use Spotlibs\PhpLib\Exceptions\InvalidRuleException;
2323
use Spotlibs\PhpLib\Libraries\MapRoute;
2424
use Spotlibs\PhpLib\Logs\Log;
25+
use Spotlibs\PhpLib\Services\Context;
26+
use Spotlibs\PhpLib\Services\Metadata;
2527
use Throwable;
2628

2729
/**
@@ -120,6 +122,8 @@ public function injectResponseHeader(array $headers): self
120122
*/
121123
public function call(Request $request, array $options = []): ResponseInterface
122124
{
125+
$context = app(Context::class);
126+
$metadata = $context->get(Metadata::class);
123127
$startime = microtime(true);
124128
$uri = $request->getUri();
125129
$url = $uri->getScheme() . "://" . $uri->getHost();
@@ -164,6 +168,8 @@ public function call(Request $request, array $options = []): ResponseInterface
164168
$respbody = "more than 5000 characters";
165169
}
166170
$logData = [
171+
'app_name' => env('APP_NAME'),
172+
'path' => is_null($metadata) ? null : $metadata->identifier,
167173
'host' => $request->getUri()->getHost(),
168174
'url' => $request->getUri()->getPath(),
169175
'request' => [
@@ -172,6 +178,7 @@ public function call(Request $request, array $options = []): ResponseInterface
172178
'body' => json_decode($reqbody, true)
173179
],
174180
'response' => [
181+
'httpCode' => $response->getStatusCode(),
175182
'headers' => $response->getHeaders(),
176183
'body' => json_decode($respbody, true)
177184
],

0 commit comments

Comments
 (0)