Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/Logger/Adapter/AppSignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,37 @@

class AppSignal extends Adapter
{
private const DEFAULT_TIMEOUT = 5;

private const DEFAULT_CONNECT_TIMEOUT = 1;

/**
* @var string (required, can be found in Appsignal -> Project -> App Settings -> Push & deploy -> Push Key)
*/
protected string $apiKey;

/**
* Timeout (seconds) for the complete request.
*/
protected int $timeout;

/**
* Timeout (seconds) for establishing the connection.
*/
protected int $connectTimeout;

/**
* AppSignal constructor.
*
* @param string $key
* @param int $timeout
* @param int $connectTimeout
*/
public function __construct(string $key)
public function __construct(string $key, int $timeout = self::DEFAULT_TIMEOUT, int $connectTimeout = self::DEFAULT_CONNECT_TIMEOUT)
{
$this->apiKey = $key;
$this->timeout = $timeout > 0 ? $timeout : self::DEFAULT_TIMEOUT;
$this->connectTimeout = $connectTimeout > 0 ? $connectTimeout : self::DEFAULT_CONNECT_TIMEOUT;
}

/**
Expand Down Expand Up @@ -114,6 +132,8 @@ public function push(Log $log): int
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => \json_encode($requestBody),
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_CONNECTTIMEOUT => $this->connectTimeout,
CURLOPT_HEADEROPT => \CURLHEADER_UNIFIED,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
];
Expand Down
20 changes: 19 additions & 1 deletion src/Logger/Adapter/LogOwl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

class LogOwl extends Adapter
{
private const DEFAULT_TIMEOUT = 5;

private const DEFAULT_CONNECT_TIMEOUT = 1;

/**
* @var string (required, can be found in LogOwl -> All Services -> Project -> Ticket -> Service Ticket)
*/
Expand All @@ -23,20 +27,34 @@ class LogOwl extends Adapter
*/
protected string $logOwlHost;

/**
* Timeout (seconds) for the complete request.
*/
protected int $timeout;

/**
* Timeout (seconds) for establishing the connection.
*/
protected int $connectTimeout;

/**
* LogOwl constructor.
*
* @param string $ticket
* @param string $host
* @param int $timeout
* @param int $connectTimeout
*/
public function __construct(string $ticket, string $host = '')
public function __construct(string $ticket, string $host = '', int $timeout = self::DEFAULT_TIMEOUT, int $connectTimeout = self::DEFAULT_CONNECT_TIMEOUT)
{
if (empty($host)) {
$host = 'https://api.logowl.io/logging/';
}

$this->ticket = $ticket;
$this->logOwlHost = $host;
$this->timeout = $timeout > 0 ? $timeout : self::DEFAULT_TIMEOUT;
$this->connectTimeout = $connectTimeout > 0 ? $connectTimeout : self::DEFAULT_CONNECT_TIMEOUT;
}

/**
Expand Down
22 changes: 21 additions & 1 deletion src/Logger/Adapter/Raygun.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,37 @@

class Raygun extends Adapter
{
private const DEFAULT_TIMEOUT = 5;

private const DEFAULT_CONNECT_TIMEOUT = 1;

/**
* @var string (required, can be found in Appsignal -> Project -> App Settings -> Push & deploy -> Push Key)
*/
protected string $apiKey;

/**
* Timeout (seconds) for the complete request.
*/
protected int $timeout;

/**
* Timeout (seconds) for establishing the connection.
*/
protected int $connectTimeout;

/**
* Raygun constructor.
*
* @param string $key
* @param int $timeout
* @param int $connectTimeout
*/
public function __construct(string $key)
public function __construct(string $key, int $timeout = self::DEFAULT_TIMEOUT, int $connectTimeout = self::DEFAULT_CONNECT_TIMEOUT)
{
$this->apiKey = $key;
$this->timeout = $timeout > 0 ? $timeout : self::DEFAULT_TIMEOUT;
$this->connectTimeout = $connectTimeout > 0 ? $connectTimeout : self::DEFAULT_CONNECT_TIMEOUT;
}

/**
Expand Down Expand Up @@ -99,6 +117,8 @@ public function push(Log $log): int
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => \json_encode($requestBody),
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_CONNECTTIMEOUT => $this->connectTimeout,
CURLOPT_HEADEROPT => \CURLHEADER_UNIFIED,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-ApiKey: '.$this->apiKey],
];
Expand Down
22 changes: 21 additions & 1 deletion src/Logger/Adapter/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

class Sentry extends Adapter
{
private const DEFAULT_TIMEOUT = 5;

private const DEFAULT_CONNECT_TIMEOUT = 1;

/**
* @var string (required, this part of Sentry DSN: 'https://{{THIS_PART}}@blabla.ingest.sentry.io/blabla')
*/
Expand All @@ -28,14 +32,26 @@ class Sentry extends Adapter
*/
protected string $sentryHost;

/**
* Timeout (seconds) for the complete request.
*/
protected int $timeout;

/**
* Timeout (seconds) for establishing the connection.
*/
protected int $connectTimeout;

/**
* Sentry constructor.
*
* @param string $projectId
* @param string $key
* @param string $host
* @param int $timeout
* @param int $connectTimeout
*/
public function __construct(string $projectId, string $key, string $host = '')
public function __construct(string $projectId, string $key, string $host = '', int $timeout = self::DEFAULT_TIMEOUT, int $connectTimeout = self::DEFAULT_CONNECT_TIMEOUT)
{
if (empty($host)) {
$host = 'https://sentry.io';
Expand All @@ -44,6 +60,8 @@ public function __construct(string $projectId, string $key, string $host = '')
$this->sentryHost = $host;
$this->sentryKey = $key;
$this->projectId = $projectId;
$this->timeout = $timeout > 0 ? $timeout : self::DEFAULT_TIMEOUT;
$this->connectTimeout = $connectTimeout > 0 ? $connectTimeout : self::DEFAULT_CONNECT_TIMEOUT;
}

/**
Expand Down Expand Up @@ -141,6 +159,8 @@ public function push(Log $log): int
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => \json_encode($requestBody),
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_CONNECTTIMEOUT => $this->connectTimeout,
CURLOPT_HEADEROPT => \CURLHEADER_UNIFIED,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-Sentry-Auth: Sentry sentry_version=7, sentry_key='.$this->sentryKey.', sentry_client=utopia-logger/'.Logger::LIBRARY_VERSION],
];
Expand Down
Loading