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 ChromePHPFormatter(); $monologResult = $monologFormatter->format($record); $telltaleFormatter = new ChromePhpTableFormatter(); $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); } $table = $record['context']['telltale-table']; $tableHeader = array_fill(0, count(reset($table)), null); $tableHeader[0] = $record['channel'] . ': ' . $record['message']; array_unshift($table, $tableHeader); return array(null, $table, 'unknown', 'table'); }
/** * @covers Monolog\Formatter\ChromePHPFormatter::formatBatch */ public function testBatchFormatThrowException() { $formatter = new ChromePHPFormatter(); $records = array(array('level' => Logger::INFO, 'level_name' => 'INFO', 'channel' => 'meh', 'context' => array(), 'datetime' => new \DateTime("@0"), 'extra' => array(), 'message' => 'log'), array('level' => Logger::WARNING, 'level_name' => 'WARNING', 'channel' => 'foo', 'context' => array(), 'datetime' => new \DateTime("@0"), 'extra' => array(), 'message' => 'log2')); $this->assertEquals(array(array('meh', 'log', 'unknown', 'info'), array('foo', 'log2', 'unknown', 'warn')), $formatter->formatBatch($records)); }