Skip to content

Commit

Permalink
FIX Don't log to the error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 6, 2025
1 parent 754ac17 commit 3c1197e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions _config/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ SilverStripe\Core\Injector\Injector:
pushDefaultLogger: [ pushLogger, [ '%$Psr\Log\LoggerInterface' ] ]
pushErrorHandler: [ pushLogger, [ '%$Psr\Log\LoggerInterface.errorhandler' ] ]

# Default implementation for use as a standard logger. Up to developers to attach their own
# handlers
# Default implementation for use as a standard logger. Used for logging custom messages.
# Projects should attach log handlers to this logging service.
Psr\Log\LoggerInterface:
type: singleton
class: Monolog\Logger
constructor:
- "error-log"
# Core error handling
# Core error handling - only uncaught exceptions and PHP errors should be caught by this handler.
# This handler displays those errors in the browser and CLI.
# Projects should not attach log handlers to this error handler service.
Psr\Log\LoggerInterface.errorhandler:
type: singleton
class: Monolog\Logger
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public function onBeforeWrite()
$email->send();
} catch (TransportExceptionInterface | RfcComplianceException $e) {
/** @var LoggerInterface $logger */
$logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
$logger = Injector::inst()->get(LoggerInterface::class);
$logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Security/MemberAuthenticator/LostPasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected function sendEmail($member, $token)
return true;
} catch (TransportExceptionInterface | RfcComplianceException $e) {
/** @var LoggerInterface $logger */
$logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
$logger = Injector::inst()->get(LoggerInterface::class);
$logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}");
return false;
}
Expand Down

0 comments on commit 3c1197e

Please sign in to comment.