Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4 * Sort composer dependencies * Remove unused Aws S3 php library * Pin simplepie dependency to ^1.5 * Pin getid3 dependency to ^1.9 * Pin composer semver to ^3.2 * Pin php-amqplib to ^2.12 * Drop sentry logging support * Update composer dependencies * Move propel regenerate to Makefile * Regenerate propel files with v1.7.0 * Pin propel orm to ^1.7 * Regenerate propel files with v1.7.2 * fix: generator_version in airtime-conf-production.php * Replace propel/propel1 with jooola/propel1 * Regenerate propel files with v1.7.3-dev * Fix php7.4 compatibility Using php-cs-fixer: '@PhpCsFixer' => true, 'concat_space' => ['spacing' => 'one'], 'ordered_class_elements' => false, 'yoda_style' => false, '@PHP74Migration' => true, 'assign_null_coalescing_to_coalesce_equal' => false, 'ternary_to_null_coalescing' => false, 'heredoc_indentation' => false, '@PHP74Migration:risky' => true, 'declare_strict_types' => false, 'void_return' => false, 'use_arrow_functions' => false, * Fix pre-commit
This commit is contained in:
parent
30b3470a06
commit
5e8d8db6e9
90 changed files with 887 additions and 1310 deletions
|
@ -89,7 +89,6 @@ class Logging
|
|||
//Escape the % symbols in any of our errors because Sentry chokes (vsprint formatting error).
|
||||
$msg = self::toString($p_msg);
|
||||
$msg = str_replace('%', '%%', $msg);
|
||||
SentryLogger::getInstance()->captureError($msg);
|
||||
}
|
||||
|
||||
public static function debug($p_msg)
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
|
||||
class SentryLogger
|
||||
{
|
||||
private static $instance;
|
||||
private $sentryClient;
|
||||
|
||||
/** Singleton getter */
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!is_null(self::$instance)) {
|
||||
return self::$instance;
|
||||
}
|
||||
self::$instance = new SentryLogger();
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
if (!file_exists(SENTRY_CONFIG_PATH)) {
|
||||
$this->sentryClient = null;
|
||||
|
||||
return;
|
||||
}
|
||||
// Instantiate a new client with a compatible DSN
|
||||
$sentry_config = parse_ini_file(SENTRY_CONFIG_PATH, false);
|
||||
$dsn = $sentry_config['dsn'];
|
||||
$this->sentryClient = new Raven_Client(
|
||||
$dsn,
|
||||
[
|
||||
//FIXME: This doesn't seem to be working...
|
||||
'processorOptions' => [
|
||||
'Raven_SanitizeDataProcessor' => [
|
||||
'fields_re' => '/(authorization|password|passwd|user_token|secret|SESSION)/i',
|
||||
'values_re' => '/^(?:\d[ -]*?){13,16}$/',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
$client = $this->sentryClient;
|
||||
|
||||
/* The Raven docs suggest not enabling these because they're "too noisy".
|
||||
// Install error handlers and shutdown function to catch fatal errors
|
||||
$error_handler = new Raven_ErrorHandler($client);
|
||||
$error_handler->registerExceptionHandler(true);
|
||||
$error_handler->registerErrorHandler(true);
|
||||
$error_handler->registerShutdownFunction(true);
|
||||
*/
|
||||
$error_handler = new Raven_ErrorHandler($client);
|
||||
$error_handler->registerExceptionHandler();
|
||||
}
|
||||
|
||||
public function captureMessage($msg)
|
||||
{
|
||||
if (!$this->sentryClient) {
|
||||
return;
|
||||
}
|
||||
$client = $this->sentryClient;
|
||||
self::addUserData($client);
|
||||
self::addTags($client);
|
||||
|
||||
// Capture a message
|
||||
$event_id = $client->getIdent($client->captureMessage($msg));
|
||||
if ($client->getLastError() !== null) {
|
||||
//printf('There was an error sending the event to Sentry: %s', $client->getLastError());
|
||||
}
|
||||
}
|
||||
|
||||
public function captureException($exception)
|
||||
{
|
||||
if (!$this->sentryClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
$client = $this->sentryClient;
|
||||
self::addUserData($client);
|
||||
self::addTags($client);
|
||||
|
||||
$event_id = $client->getIdent($client->captureException($exception, [
|
||||
'extra' => $this->getExtraData(),
|
||||
'tags' => $this->getTags(),
|
||||
]));
|
||||
$client->context->clear();
|
||||
}
|
||||
|
||||
public function captureError($errorMessage)
|
||||
{
|
||||
if (!$this->sentryClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
$client = $this->sentryClient;
|
||||
|
||||
// Provide some additional data with an exception
|
||||
self::addUserData($client);
|
||||
self::addTags($client);
|
||||
$event_id = $client->getIdent($client->captureMessage($errorMessage, [
|
||||
'extra' => $this->getExtraData(),
|
||||
]));
|
||||
$client->context->clear();
|
||||
}
|
||||
|
||||
private static function getTags()
|
||||
{
|
||||
$tags = [];
|
||||
$config = Config::getConfig();
|
||||
$tags['Development Environment'] = $config['dev_env'];
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
private static function addTags($client)
|
||||
{
|
||||
$client->tags_context(self::getTags());
|
||||
}
|
||||
|
||||
private static function addUserData($client)
|
||||
{
|
||||
$userData = [];
|
||||
$userData['client_id'] = Application_Model_Preference::GetClientId();
|
||||
$userData['station_url'] = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : '';
|
||||
$client->user_context($userData);
|
||||
}
|
||||
|
||||
/** Extra data to log with Sentry */
|
||||
private function getExtraData()
|
||||
{
|
||||
$extraData = [];
|
||||
$extraData['php_version'] = phpversion();
|
||||
$extraData['client_id'] = Application_Model_Preference::GetClientId();
|
||||
|
||||
return $extraData;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue