mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 20:27:31 +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;
|
||||||
|
|
||||||
@@ -58,15 +57,13 @@ class LogstashFormatter extends NormalizerFormatter
|
|||||||
*/
|
*/
|
||||||
public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0)
|
public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0)
|
||||||
{
|
{
|
||||||
//log stash requires a ISO 8601 format date
|
// logstash requires a ISO 8601 format date
|
||||||
parent::__construct('c');
|
parent::__construct('c');
|
||||||
|
|
||||||
$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);
|
} else {
|
||||||
break;
|
$message = $this->formatV0($record);
|
||||||
case self::V0:
|
|
||||||
default:
|
|
||||||
$message = $this->formatV0($record);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toJson($message) . "\n";
|
return $this->toJson($message) . "\n";
|
||||||
|
@@ -78,7 +78,7 @@ class NewRelicHandler extends AbstractProcessingHandler
|
|||||||
* Returns the appname where this log should be sent. Each log can override the default appname, set in this
|
* Returns the appname where this log should be sent. Each log can override the default appname, set in this
|
||||||
* handler's constructor, by providing the appname in its context.
|
* handler's constructor, by providing the appname in its context.
|
||||||
*
|
*
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
protected function getAppName(array $context)
|
protected function getAppName(array $context)
|
||||||
|
@@ -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