Skip to content

Commit

Permalink
Added audit logging to FBS handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Dec 9, 2024
1 parent 4ea0f62 commit 2ce4685
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ before starting to add changes. Use example [placed in the end of the page](#exa

- Added webform ID to digital post audit logging messages.
- Added audit logging to `os2forms_fasit`
- Added audit logging to `os2forms_fbs_handler`

## [3.19.0] 2024-12-06

Expand Down
1 change: 1 addition & 0 deletions modules/os2forms_fbs_handler/os2forms_fbs_handler.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ core_version_requirement: ^9 || ^10
dependencies:
- 'webform:webform'
- 'advancedqueue:advancedqueue'
- 'os2web:os2web_audit'
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Drupal\os2forms_fbs_handler\Client\FBS;
use Drupal\os2forms_fbs_handler\Client\Model\Guardian;
use Drupal\os2forms_fbs_handler\Client\Model\Patron;
use Drupal\os2web_audit\Service\Logger;
use Drupal\webform\Entity\WebformSubmission;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
Expand Down Expand Up @@ -41,6 +42,7 @@ public function __construct(
$plugin_definition,
LoggerChannelFactoryInterface $loggerFactory,
protected readonly Client $client,
protected readonly Logger $auditLogger,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->submissionLogger = $loggerFactory->get('webform_submission');
Expand All @@ -55,7 +57,8 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id,
$plugin_definition,
$container->get('logger.factory'),
$container->get('http_client')
$container->get('http_client'),
$container->get('os2web_audit.logger'),
);
}

Expand Down Expand Up @@ -121,6 +124,9 @@ public function process(Job $job): JobResult {

$this->submissionLogger->notice($this->t('The submission #@serial was successfully delivered', ['@serial' => $webformSubmission->serial()]), $logger_context);

$msg = sprintf('Successfully created FBS patron with cpr %s and guardian with cpr %s. Webform id %s.', $data['barn_cpr'], $data['cpr'], $webformSubmission->getWebform()->id());
$this->auditLogger->info('FBS', $msg);

return JobResult::success();
}
catch (\Exception | GuzzleException $e) {
Expand Down

0 comments on commit 2ce4685

Please sign in to comment.