-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
200 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ composer.lock | |
.bash_history | ||
/.phpunit.result.cache | ||
.DS_Store | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# simplesamlphp-module-rollbar changelog | ||
All notable changes to simplesamlphp-module-rollbar will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [unreleased] | ||
- | ||
|
||
## [v1.0.1] | ||
- Add exception handling as an alternative to logger. | ||
|
||
## [v1.0.0] | ||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Utilize hook provided by SimpleSAMLphp to log PHP exceptions. | ||
* @see https://simplesamlphp.org/docs/stable/simplesamlphp-modules.html#hook-interface | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Rollbar\Payload\Level; | ||
use Rollbar\Rollbar; | ||
use SimpleSAML\Configuration; | ||
|
||
/** | ||
* Hook to run a cron job. | ||
* | ||
* @param Throwable $exception | ||
* The exception. | ||
* | ||
* @throws Throwable | ||
*/ | ||
function rollbar_hook_exception_handler(Throwable $exception): void { | ||
// Check if Rollbar is configured to handle exceptions. | ||
$config = Configuration::getConfig(); | ||
$enabled = $config->getOptionalBoolean('rollbar.exception_handler', FALSE); | ||
$token = $config->getOptionalString('rollbar.token', ''); | ||
$environment = $config->getOptionalString('rollbar.environment', ''); | ||
|
||
if ($enabled && $token && $environment) { | ||
// Initialize and configure the logger. | ||
Rollbar::init([ | ||
'access_token' => $token, | ||
'environment' => $environment, | ||
], FALSE, FALSE, FALSE); | ||
|
||
// Log the exception. | ||
Rollbar::logger()->report(Level::ERROR, $exception, isUncaught: TRUE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="rollbar"> | ||
<description>The coding standard for rollbar.</description> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="phpcs-standard"> | ||
<description>Drupal based codestyle ruleset</description> | ||
|
||
<rule ref="PSR12" /> | ||
<file>./src</file> | ||
<file>./public</file> | ||
<!-- Specify standards. --> | ||
<rule ref="Drupal"/> | ||
<rule ref="DrupalPractice"/> | ||
|
||
<!-- Include path with the Drupal and DrupalPractice rules. --> | ||
<config name="installed_paths" value="vendor/drupal/coder/coder_sniffer"/> | ||
|
||
<!-- Specify folders. --> | ||
<file>./hooks</file> | ||
<file>./src</file> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters