ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LogglyFormatterTest.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\Formatter;
13 
15 
17 {
21  public function testConstruct()
22  {
23  $formatter = new LogglyFormatter();
24  $this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
26  $this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
27  }
28 
32  public function testFormat()
33  {
34  $formatter = new LogglyFormatter();
35  $record = $this->getRecord();
36  $formatted_decoded = json_decode($formatter->format($record), true);
37  $this->assertArrayHasKey("timestamp", $formatted_decoded);
38  $this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]);
39  }
40 }
Encodes message information into JSON in a format compatible with Loggly.
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19