MonologProcessorPsrLogMessageProcessor

Processes a record's message according to PSR-3 rules.

Defined (1)

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

/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php  
  1. class PsrLogMessageProcessor 
  2. /** 
  3. * @param array $record 
  4. * @return array 
  5. */ 
  6. public function __invoke(array $record) 
  7. if (false === strpos($record['message'], '{')) { 
  8. return $record; 
  9.  
  10. $replacements = array(); 
  11. foreach ($record['context'] as $key => $val) { 
  12. if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) { 
  13. $replacements['{'.$key.'}'] = $val; 
  14. } elseif (is_object($val)) { 
  15. $replacements['{'.$key.'}'] = '[object '.get_class($val).']'; 
  16. } else { 
  17. $replacements['{'.$key.'}'] = '['.gettype($val).']'; 
  18.  
  19. $record['message'] = strtr($record['message'], $replacements); 
  20.  
  21. return $record;