Skip to content

Commit 2f8d45b

Browse files
committed
extracted http writer url to parameters
1 parent 7d59b24 commit 2f8d45b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Service/BugCatcher.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function log(array $data): void {
3131

3232
public function logRecord(string $message, int $level, ?string $requestUri = null, array $additional = []): void {
3333
$this->writer->write([
34+
"api_uri" => "/api/record_logs",
3435
"message" => $message,
3536
"level" => $level,
3637
"projectCode" => $this->project,
@@ -44,6 +45,7 @@ public function logException(\Throwable $throwable, int $level = 500, ?string $r
4445
$stackTrace = $this->collectFrames($throwable->getTraceAsString());
4546
}
4647
$data = [
48+
"api_uri" => "/api/record_log_traces",
4749
"message" => $throwable->getMessage(),
4850
"level" => $level,
4951
"projectCode" => $this->project,

src/Writer/HttpWriter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public function __construct(
1818
) {}
1919

2020
function write(array $data): void {
21-
$path = $data['stackTrace']??false ? "/api/record_log_traces" : "/api/record_logs";
21+
if (!array_key_exists("api_uri", $data)) {
22+
throw new Exception("api_uri not porvided for logging to bugcatcher");
23+
}
24+
$path = $data["api_uri"];
25+
unset($data["api_uri"]);
2226
$response = $this->client->request("POST", $path, [
2327
'headers' => [
2428
'Content-Type' => 'application/json',

0 commit comments

Comments
 (0)