ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ErrorLogHandlerTest.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 
12 namespace Monolog\Handler;
13 
15 use Monolog\Logger;
17 
18 function error_log()
19 {
20  $GLOBALS['error_log'][] = func_get_args();
21 }
22 
24 {
25  protected function setUp()
26  {
27  $GLOBALS['error_log'] = array();
28  }
29 
36  {
37  new ErrorLogHandler(42);
38  }
39 
44  {
47  $handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
48  $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
49 
50  $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
51  $this->assertSame($GLOBALS['error_log'][0][1], $type);
52 
53  $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
54  $handler->setFormatter(new LineFormatter(null, null, true));
55  $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
56 
57  $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
58  $this->assertSame($GLOBALS['error_log'][1][1], $type);
59 
60  $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
61  $this->assertSame($GLOBALS['error_log'][2][1], $type);
62 
63  $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
64  $this->assertSame($GLOBALS['error_log'][3][1], $type);
65  }
66 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
const ERROR
Runtime errors.
Definition: Logger.php:57
$type
testShouldLogMessagesUsingErrorLogFuncion()
Monolog::write
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Stores to PHP error_log() handler.
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
testShouldNotAcceptAnInvalidTypeOnContructor()
Monolog::__construct InvalidArgumentException The given message type "42" is not supported ...
Create styles array
The data for the language used.
Formats incoming records into a one-line string.
$handler