Skip to content

Commit

Permalink
Updated Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjalg13 committed Jul 27, 2023
1 parent 59f50cc commit 6af35e1
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/Logger/Adapter/RollBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class RollBar extends Adapter
{

/**
* @var string (required, can be found in Appsignal -> Project -> App Settings -> Push & deploy -> Push Key)
*/
Expand All @@ -25,13 +24,13 @@ class RollBar extends Adapter
*/
public static function getName(): string
{
return "rollBar";
return 'rollBar';
}

/**
* Push log to external provider
*
* @param Log $log
* @param Log $log
* @return int
*/
public function push(Log $log): int
Expand All @@ -51,13 +50,12 @@ public function push(Log $log): int
$tagsArray = [];

foreach ($log->getTags() as $tagKey => $tagValue) {
\array_push($tagsArray, $tagKey . ': ' . $tagValue);
\array_push($tagsArray, $tagKey.': '.$tagValue);
}

\array_push($tagsArray, 'type: ' . $log->getType());
\array_push($tagsArray, 'environment: ' . $log->getEnvironment());
\array_push($tagsArray, 'sdk: utopia-logger/' . Logger::LIBRARY_VERSION);

\array_push($tagsArray, 'type: '.$log->getType());
\array_push($tagsArray, 'environment: '.$log->getEnvironment());
\array_push($tagsArray, 'sdk: utopia-logger/'.Logger::LIBRARY_VERSION);

if (! empty($log->getUser()) && ! empty($log->getUser()->getId())) {
$tags['userId'] = $log->getUser()->getId();
Expand All @@ -75,18 +73,16 @@ public function push(Log $log): int
'environment' => $log->getEnvironment(),
'body' => [
'message' => [
'body' => $log->getMessage()
'body' => $log->getMessage(),
],
'timestamp' => \intval($log->getTimestamp()),
],
'trace_chain' => $breadcrumbsArray,
'level' => $log->getType(),
'custom' => $tagsArray
]
'custom' => $tagsArray,
],
];



// init curl object
$ch = \curl_init();

Expand All @@ -97,7 +93,7 @@ public function push(Log $log): int
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => \json_encode($requestBody),
CURLOPT_HEADEROPT => \CURLHEADER_UNIFIED,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-Rollbar-Access-Token: ' . $this->apiKey],
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-Rollbar-Access-Token: '.$this->apiKey],
];

// apply those options
Expand All @@ -107,20 +103,19 @@ public function push(Log $log): int
$result = \curl_exec($ch);
$response = \curl_getinfo($ch, \CURLINFO_HTTP_CODE);

if (!$result && $response >= 400) {
throw new Exception('Log could not be pushed with status code ' . $response . ': ' . \curl_error($ch));
if (! $result && $response >= 400) {
throw new Exception('Log could not be pushed with status code '.$response.': '.\curl_error($ch));
}

\curl_close($ch);

return $response;

}

/**
* RollBar constructor.
*
* @param string $configKey
* @param string $configKey
*/
public function __construct(string $configKey)
{
Expand Down Expand Up @@ -154,4 +149,4 @@ public function getSupportedBreadcrumbTypes(): array
Log::TYPE_ERROR,
];
}
}
}

0 comments on commit 6af35e1

Please sign in to comment.