Skip to content
Snippets Groups Projects
Commit 2c141427 authored by Christian Eichert's avatar Christian Eichert
Browse files

new Sentry Warning Method

	modified:   classes/class.F.php
	modified:   composer.json
parent 7a8b6321
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,36 @@ class F{
}
/**
* Sends a message to Sentry
*
* @param string $message
* @param string $level [warning, error, fatal]
* @return void
*/
static function captureMessage(string $message = null, string $level = "warning"): void
{
$level_arr = ["warning","error","fatal"];
if( in_array($level, $level_arr) AND
method_exists("\\Sentry\\Sentry", "captureMessage") and
method_exists("\\Sentry\\Sentry", "withScope")
){
\Sentry\withScope(function (\Sentry\State\Scope $scope) use ($message, $level): void
{
if ($level == "error")
$scope->setLevel(\Sentry\Severity::error());
if ($level == "warning")
$scope->setLevel(\Sentry\Severity::warning());
if ($level == "fatal")
$scope->setLevel(\Sentry\Severity::fatal());
if (isset($message)) {
// Use the $message variable instead of hardcoded string
\Sentry\captureMessage($message);
}
});
}
}
}
?>
......@@ -13,6 +13,7 @@
"require": {
"php": "^7.2|^7.4|^8.0|^8.2|^8.3",
"mobiledetect/mobiledetectlib": "^2.8.40",
"sentry/sentry": "^3.*",
"vlucas/phpdotenv": "^5.5",
"ext-json": "*"
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment