-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VACMS-19175: new monolog current user processor (#19338)
- Loading branch information
1 parent
cc54684
commit a7e9d9d
Showing
6 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
docroot/modules/custom/va_gov_user/src/Logger/Processor/VaGovUserCurrentUserProcessor.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,46 @@ | ||
<?php | ||
|
||
namespace Drupal\va_gov_user\Logger\Processor; | ||
|
||
use Drupal\Core\Session\AccountProxyInterface; | ||
use Monolog\LogRecord; | ||
use Monolog\Processor\ProcessorInterface; | ||
|
||
/** | ||
* Processor that adds user information to the log records. | ||
*/ | ||
class VaGovUserCurrentUserProcessor implements ProcessorInterface { | ||
|
||
/** | ||
* The current user. | ||
* | ||
* @var \Drupal\Core\Session\AccountProxyInterface | ||
*/ | ||
protected AccountProxyInterface $accountProxy; | ||
|
||
/** | ||
* Constructs a Default object. | ||
* | ||
* @param \Drupal\Core\Session\AccountProxyInterface $account_proxy | ||
* The current user. | ||
*/ | ||
public function __construct(AccountProxyInterface $account_proxy) { | ||
$this->accountProxy = $account_proxy; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __invoke(LogRecord $record): LogRecord { | ||
$record->extra = \array_merge( | ||
$record->extra, | ||
[ | ||
'uid' => $this->accountProxy->id(), | ||
'user' => $this->accountProxy->id(), | ||
], | ||
); | ||
|
||
return $record; | ||
} | ||
|
||
} |
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