ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
PsrLogMessageProcessor.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Monolog\Processor;
13
22{
27 public function __invoke(array $record)
28 {
29 if (false === strpos($record['message'], '{')) {
30 return $record;
31 }
32
33 $replacements = array();
34 foreach ($record['context'] as $key => $val) {
35 if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) {
36 $replacements['{'.$key.'}'] = $val;
37 } elseif (is_object($val)) {
38 $replacements['{'.$key.'}'] = '[object '.get_class($val).']';
39 } else {
40 $replacements['{'.$key.'}'] = '['.gettype($val).']';
41 }
42 }
43
44 $record['message'] = strtr($record['message'], $replacements);
45
46 return $record;
47 }
48}
Processes a record's message according to PSR-3 rules.