-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UHF-10131: Repurpose grants_logger module for sentry logging * UHF-10131: Fix typo * UHF-10131: Code deduplication * UHF-10131: Capture exceptions * UHF-10131: Remove comment
- Loading branch information
Showing
12 changed files
with
107 additions
and
146 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
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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
name: 'Grants Logger' | ||
type: module | ||
description: 'Grants logger override.' | ||
description: 'Grants logging customization' | ||
package: 'helfi' | ||
core_version_requirement: ^9 || ^10 | ||
core_version_requirement: ^10 || ^11 | ||
dependencies: | ||
- helfi_helsinki_profiili | ||
- raven:raven | ||
- helfi_atv:helfi_atv | ||
- helfi_helsinki_profiili:helfi_helsinki_profiili |
10 changes: 5 additions & 5 deletions
10
public/modules/custom/grants_logger/grants_logger.services.yml
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,6 +1,6 @@ | ||
services: | ||
logger.dblog: | ||
class: Drupal\grants_logger\Logger\GrantsLogger | ||
arguments: ['@database', '@logger.log_message_parser', '@helfi_helsinki_profiili.userdata'] | ||
tags: | ||
- { name: logger } | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
|
||
Drupal\grants_logger\EventSubscriber\SentryEventSubscriber: ~ |
49 changes: 49 additions & 0 deletions
49
public/modules/custom/grants_logger/src/EventSubscriber/SentryEventSubscriber.php
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,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\grants_logger\EventSubscriber; | ||
|
||
use Drupal\helfi_atv\Event\AtvServiceExceptionEvent; | ||
use Drupal\helfi_helsinki_profiili\Event\HelsinkiProfiiliExceptionEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* Forwards events to Sentry. | ||
*/ | ||
final class SentryEventSubscriber implements EventSubscriberInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents(): array { | ||
return [ | ||
AtvServiceExceptionEvent::EVENT_ID => 'onAtvException', | ||
HelsinkiProfiiliExceptionEvent::EVENT_ID => 'onHelsinkiProfiiliException', | ||
]; | ||
} | ||
|
||
/** | ||
* Logs the event to sentry. | ||
* | ||
* @param \Drupal\helfi_atv\Event\AtvServiceExceptionEvent $event | ||
* An exception event. | ||
*/ | ||
public function onAtvException(AtvServiceExceptionEvent $event): void { | ||
// Consider ignoring the event if $event is instanceof GuzzleException | ||
// and http error status code is _some_status_code_ if, for example, 404 | ||
// errors cause too much error spam here. | ||
\Sentry\captureException($event->getException()); | ||
} | ||
|
||
/** | ||
* Logs the event to sentry. | ||
* | ||
* @param \Drupal\helfi_helsinki_profiili\Event\HelsinkiProfiiliExceptionEvent $event | ||
* An exception event. | ||
*/ | ||
public function onHelsinkiProfiiliException(HelsinkiProfiiliExceptionEvent $event): void { | ||
\Sentry\captureException($event->getException()); | ||
} | ||
|
||
} |
72 changes: 0 additions & 72 deletions
72
public/modules/custom/grants_logger/src/Logger/GrantsLogger.php
This file was deleted.
Oops, something went wrong.
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