1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 17:16:18 +02:00

Fix #150: Table formatter for FirePHP

This commit is contained in:
Witold Wasiczko
2014-03-27 14:37:18 +01:00
parent 4cf49e5496
commit 399d10bcf0

View File

@@ -22,6 +22,9 @@ use Monolog\Logger;
*/ */
class WildfireFormatter extends NormalizerFormatter class WildfireFormatter extends NormalizerFormatter
{ {
const TABLE = 'TABLE';
const CONTEXT_TABLE_KEY = 'table';
/** /**
* Translates Monolog log levels to Wildfire levels. * Translates Monolog log levels to Wildfire levels.
*/ */
@@ -67,15 +70,24 @@ class WildfireFormatter extends NormalizerFormatter
$message = reset($message); $message = reset($message);
} }
if(isset($record['context'][self::CONTEXT_TABLE_KEY])){
$type = self::TABLE;
$label = $record['message'];
$message = $record['context'][self::CONTEXT_TABLE_KEY];
} else {
$type = $this->logLevels[$record['level']];
$label = $record['channel'];
}
// Create JSON object describing the appearance of the message in the console // Create JSON object describing the appearance of the message in the console
$json = $this->toJson(array( $json = $this->toJson(array(
array( array(
'Type' => $this->logLevels[$record['level']], 'Type' => $type,
'File' => $file, 'File' => $file,
'Line' => $line, 'Line' => $line,
'Label' => $record['channel'], 'Label' => $label,
), ),
$message, $message
), $handleError); ), $handleError);
// The message itself is a serialization of the above JSON object + it's length // The message itself is a serialization of the above JSON object + it's length