ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
WildfireFormatterTest.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 
14 use Monolog\Logger;
15 
17 {
21  public function testDefaultFormat()
22  {
23  $wildfire = new WildfireFormatter();
24  $record = array(
25  'level' => Logger::ERROR,
26  'level_name' => 'ERROR',
27  'channel' => 'meh',
28  'context' => array('from' => 'logger'),
29  'datetime' => new \DateTime("@0"),
30  'extra' => array('ip' => '127.0.0.1'),
31  'message' => 'log',
32  );
33 
34  $message = $wildfire->format($record);
35 
36  $this->assertEquals(
37  '125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},'
38  .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
39  $message
40  );
41  }
42 
46  public function testFormatWithFileAndLine()
47  {
48  $wildfire = new WildfireFormatter();
49  $record = array(
50  'level' => Logger::ERROR,
51  'level_name' => 'ERROR',
52  'channel' => 'meh',
53  'context' => array('from' => 'logger'),
54  'datetime' => new \DateTime("@0"),
55  'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
56  'message' => 'log',
57  );
58 
59  $message = $wildfire->format($record);
60 
61  $this->assertEquals(
62  '129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},'
63  .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
64  $message
65  );
66  }
67 
71  public function testFormatWithoutContext()
72  {
73  $wildfire = new WildfireFormatter();
74  $record = array(
75  'level' => Logger::ERROR,
76  'level_name' => 'ERROR',
77  'channel' => 'meh',
78  'context' => array(),
79  'datetime' => new \DateTime("@0"),
80  'extra' => array(),
81  'message' => 'log',
82  );
83 
84  $message = $wildfire->format($record);
85 
86  $this->assertEquals(
87  '58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|',
88  $message
89  );
90  }
91 
97  {
98  $wildfire = new WildfireFormatter();
99  $record = array(
100  'level' => Logger::ERROR,
101  'level_name' => 'ERROR',
102  'channel' => 'meh',
103  'context' => array(),
104  'datetime' => new \DateTime("@0"),
105  'extra' => array(),
106  'message' => 'log',
107  );
108 
109  $wildfire->formatBatch(array($record));
110  }
111 
115  public function testTableFormat()
116  {
117  $wildfire = new WildfireFormatter();
118  $record = array(
119  'level' => Logger::ERROR,
120  'level_name' => 'ERROR',
121  'channel' => 'table-channel',
122  'context' => array(
124  array('col1', 'col2', 'col3'),
125  array('val1', 'val2', 'val3'),
126  array('foo1', 'foo2', 'foo3'),
127  array('bar1', 'bar2', 'bar3'),
128  ),
129  ),
130  'datetime' => new \DateTime("@0"),
131  'extra' => array(),
132  'message' => 'table-message',
133  );
134 
135  $message = $wildfire->format($record);
136 
137  $this->assertEquals(
138  '171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|',
139  $message
140  );
141  }
142 }
const ERROR
Runtime errors.
Definition: Logger.php:57
testBatchFormatThrowException()
Monolog::formatBatch BadMethodCallException
Create styles array
The data for the language used.
Serializes a log message according to Wildfire&#39;s header requirements.