silverstripe / silverstripe-raygun

Raygun.com integration for PHP
BSD 3-Clause "New" or "Revised" License
6 stars 23 forks source link

Documentation is not clear that Raygun error handling replaces default error handling #70

Open brettt89 opened 1 year ago

brettt89 commented 1 year ago

Logger configuration in _config/config.yml overrides the default LoggerInterface framework configuration, adding a "Handler", resulting in default logging handler no longer working.

SilverStripe\Core\Injector\Injector:
  Psr\Log\LoggerInterface:
    calls:
      - [ pushHandler, [ '%$SilverStripe\Raygun\RaygunHandler' ]]

Silverstripe Framework by default does not add any handlers to this interface which results in Monolog sending it to php://stderr by default.

https://github.com/silverstripe/silverstripe-framework/blob/4/_config/logging.yml#L19-L25

  # Default implementation for use as a standard logger. Up to developers to attach their own
  # handlers
  Psr\Log\LoggerInterface:
    type: singleton
    class: Monolog\Logger
    constructor:
      - "error-log"

https://github.com/Seldaek/monolog/blob/1.27.1/src/Monolog/Logger.php#L292-L296

    public function addRecord($level, $message, array $context = array())
    {
        if (!$this->handlers) {
            $this->pushHandler(new StreamHandler('php://stderr', static::DEBUG));
        }

With this Raygun module adding a handler to the LoggerInterface, this default is no longer used resulting in logs no longer being sent to php://stderr.

This may be by design of this module, however it is not clear in the README.md that this replaces the default logger with Raygun logging (meaning all logging to php://sterr will stop unless specifically added as a StreamHandler to LoggerInterface).