Author: Eric Clemmons (@ericclemmons) (eric@uxdriven.com)
Author: Christophe Coevoet (stof@notk.org)
Author: Kirill chEbba Chebunin (iam@chebba.org)
Inheritance: extends Monolog\Formatter\NormalizerFormatter
 /**
  * @covers Monolog\Formatter\WildfireFormatter::format
  */
 public function testDefaultFormatIsLineFormatterWithoutNewLine()
 {
     $wildfire = new WildfireFormatter();
     $record = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'meh', 'context' => array('from' => 'logger'), 'datetime' => new \DateTime("@0"), 'extra' => array('ip' => '127.0.0.1'), 'message' => 'log');
     $message = $wildfire->format($record);
     $this->assertEquals('125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},' . '{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', $message);
 }
 /**
  * @covers Monolog\Formatter\WildfireFormatter::format
  */
 public function testTableFormat()
 {
     $wildfire = new WildfireFormatter();
     $record = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'table-channel', 'context' => array(WildfireFormatter::TABLE => array(array('col1', 'col2', 'col3'), array('val1', 'val2', 'val3'), array('foo1', 'foo2', 'foo3'), array('bar1', 'bar2', 'bar3'))), 'datetime' => new \DateTime("@0"), 'extra' => array(), 'message' => 'table-message');
     $message = $wildfire->format($record);
     $this->assertEquals('171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|', $message);
 }
 public function testDefaultFormatIsLineFormatterWithoutNewLine()
 {
     $wildfire = new WildfireFormatter();
     $record = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'meh', 'context' => array(), 'datetime' => new \DateTime(), 'extra' => array('ip' => '127.0.0.1'), 'message' => 'log');
     $message = $wildfire->format($record);
     $this->assertEquals('84|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log [] {\\"ip\\":\\"127.0.0.1\\"}"]|', $message);
 }
 public function testContextEffectivity()
 {
     $record = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'meh', 'context' => array('from' => 'logger', 'telltale-table' => array(array('cell-0-0', 'cell-0-1'), array('cell-1-0', 'cell-1-1'))), 'datetime' => new \DateTime("@0"), 'extra' => array('ip' => '127.0.0.1'), 'message' => 'log');
     $monologFormatter = new WildfireFormatter();
     $monologResult = $monologFormatter->format($record);
     $telltaleFormatter = new WildfireTableFormatter();
     $telltaleResult = $telltaleFormatter->format($record);
     $this->assertNotEquals($monologResult, $telltaleResult);
 }
 /**
  * {@inheritdoc}
  */
 public function format(array $record)
 {
     if (!isset($record['context']['telltale-table']) || !is_array($record['context']['telltale-table'])) {
         return parent::format($record);
     }
     $record = $this->normalize($record);
     $type = 'TABLE';
     $file = isset($record['extra']['file']) ? $record['extra']['file'] : '';
     $line = isset($record['extra']['line']) ? $record['extra']['line'] : '';
     $label = $record['channel'] . ': ' . $record['message'];
     $message = $record['context']['telltale-table'];
     $handleError = false;
     $json = $this->toJson(array(array('Type' => $type, 'File' => $file, 'Line' => $line, 'Label' => $label), $message), $handleError);
     return sprintf('%s|%s|', strlen($json), $json);
 }
 /**
  * @covers Monolog\Formatter\WildfireFormatter::formatBatch
  * @expectedException BadMethodCallException
  */
 public function testBatchFormatThrowException()
 {
     $wildfire = new WildfireFormatter();
     $record = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'meh', 'context' => array(), 'datetime' => new \DateTime("@0"), 'extra' => array(), 'message' => 'log');
     $wildfire->formatBatch(array($record));
 }