ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
PsrLogCompatTest.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;
13
18
20{
21 private $handler;
22
23 public function getLogger()
24 {
25 $logger = new Logger('foo');
26 $logger->pushHandler($handler = new TestHandler);
27 $logger->pushProcessor(new PsrLogMessageProcessor);
28 $handler->setFormatter(new LineFormatter('%level_name% %message%'));
29
30 $this->handler = $handler;
31
32 return $logger;
33 }
34
35 public function getLogs()
36 {
37 $convert = function ($record) {
38 $lower = function ($match) {
39 return strtolower($match[0]);
40 };
41
42 return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']);
43 };
44
45 return array_map($convert, $this->handler->getRecords());
46 }
47}
Formats incoming records into a one-line string.
Used for testing purposes.
Definition: TestHandler.php:69
Monolog log channel.
Definition: Logger.php:28
Processes a record's message according to PSR-3 rules.
getLogs()
This must return the log messages in order with a simple formatting: "<LOG LEVEL> <MESSAGE>".
Provides a base test class for ensuring compliance with the LoggerInterface.