Google_Logger_Psr

Psr logging class based on the PSR-3 standard.

Defined (1)

The class is defined in the following location(s).

/vendor/google/apiclient/src/Google/Logger/Psr.php  
  1. class Google_Logger_Psr extends Google_Logger_Abstract 
  2. /** 
  3. * @param Psr\Log\LoggerInterface $logger The PSR-3 logger 
  4. */ 
  5. private $logger; 
  6.  
  7. /** 
  8. * @param Google_Client $client The current Google client 
  9. * @param Psr\Log\LoggerInterface $logger PSR-3 logger where logging will be delegated. 
  10. */ 
  11. public function __construct(Google_Client $client, /**Psr\Log\LoggerInterface*/ $logger = null) 
  12. parent::__construct($client); 
  13.  
  14. if ($logger) { 
  15. $this->setLogger($logger); 
  16.  
  17. /** 
  18. * Sets the PSR-3 logger where logging will be delegated. 
  19. * NOTE: The `$logger` should technically implement 
  20. * `Psr\Log\LoggerInterface`, but we don't explicitly require this so that 
  21. * we can be compatible with PHP 5.2. 
  22. * @param Psr\Log\LoggerInterface $logger The PSR-3 logger 
  23. */ 
  24. public function setLogger(/**Psr\Log\LoggerInterface*/ $logger) 
  25. $this->logger = $logger; 
  26.  
  27. /** 
  28. * {@inheritdoc} 
  29. */ 
  30. public function shouldHandle($level) 
  31. return isset($this->logger) && parent::shouldHandle($level); 
  32.  
  33. /** 
  34. * {@inheritdoc} 
  35. */ 
  36. public function log($level, $message, array $context = array()) 
  37. if (!$this->shouldHandle($level)) { 
  38. return false; 
  39.  
  40. if ($context) { 
  41. $this->reverseJsonInContext($context); 
  42.  
  43. $levelName = is_int($level) ? array_search($level, self::$levels) : $level; 
  44. $this->logger->log($levelName, $message, $context); 
  45.  
  46. /** 
  47. * {@inheritdoc} 
  48. */ 
  49. protected function write($message, array $context = array())