mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 12:17:35 +02:00
Formatting fixes
This commit is contained in:
@@ -21,7 +21,6 @@ namespace Monolog\Formatter;
|
|||||||
*/
|
*/
|
||||||
class LogstashFormatter extends NormalizerFormatter
|
class LogstashFormatter extends NormalizerFormatter
|
||||||
{
|
{
|
||||||
|
|
||||||
const V0 = 0;
|
const V0 = 0;
|
||||||
const V1 = 1;
|
const V1 = 1;
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ class LogstashFormatter extends NormalizerFormatter
|
|||||||
protected $contextPrefix;
|
protected $contextPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var integer LogStash format version to use
|
* @var integer logstash format version to use
|
||||||
*/
|
*/
|
||||||
protected $version;
|
protected $version;
|
||||||
|
|
||||||
@@ -63,10 +62,8 @@ class LogstashFormatter extends NormalizerFormatter
|
|||||||
|
|
||||||
$this->systemName = $systemName ?: gethostname();
|
$this->systemName = $systemName ?: gethostname();
|
||||||
$this->applicationName = $applicationName;
|
$this->applicationName = $applicationName;
|
||||||
|
|
||||||
$this->extraPrefix = $extraPrefix;
|
$this->extraPrefix = $extraPrefix;
|
||||||
$this->contextPrefix = $contextPrefix;
|
$this->contextPrefix = $contextPrefix;
|
||||||
|
|
||||||
$this->version = $version;
|
$this->version = $version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,14 +74,10 @@ class LogstashFormatter extends NormalizerFormatter
|
|||||||
{
|
{
|
||||||
$record = parent::format($record);
|
$record = parent::format($record);
|
||||||
|
|
||||||
switch ($this->version) {
|
if ($this->version === self::V1) {
|
||||||
case self::V1:
|
|
||||||
$message = $this->formatV1($record);
|
$message = $this->formatV1($record);
|
||||||
break;
|
} else {
|
||||||
case self::V0:
|
|
||||||
default:
|
|
||||||
$message = $this->formatV0($record);
|
$message = $this->formatV0($record);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toJson($message) . "\n";
|
return $this->toJson($message) . "\n";
|
||||||
|
@@ -158,7 +158,6 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('app', $message['@type']);
|
$this->assertEquals('app', $message['@type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Monolog\Formatter\LogstashFormatter::format
|
* @covers Monolog\Formatter\LogstashFormatter::format
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user