TestLog.php in Drupal 8        
                          
                  
                        
  
  
  
  
File
  core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php
  
    View source  
  <?php
namespace Drupal\error_service_test\Logger;
use Drupal\Core\Logger\RfcLoggerTrait;
use Psr\Log\LoggerInterface;
class TestLog implements LoggerInterface {
  use RfcLoggerTrait;
  
  public function log($level, $message, array $context = []) {
    $trigger = [
      '%type' => 'Exception',
      '@message' => 'Deforestation',
      '%function' => 'Drupal\\error_service_test\\MonkeysInTheControlRoom->handle()',
      'severity_level' => 3,
      'channel' => 'php',
    ];
    if (array_diff_assoc($trigger, $context) === []) {
      throw new \Exception('Oh, oh, frustrated monkeys!');
    }
  }
}
 
Classes
        
  
  
      
      
         
      
                  
            Name            | 
                  
            Description           | 
              
    
    
          
                  | 
            TestLog           | 
                  
            Throws an exception while logging an exception.           |