1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-01 19:00:20 +02:00

Formatting fixes

This commit is contained in:
Jordi Boggiano
2013-09-16 11:55:31 +02:00
parent 466b1333fd
commit 99aad2e059
3 changed files with 7 additions and 15 deletions

View File

@@ -21,7 +21,6 @@ namespace Monolog\Formatter;
*/
class LogstashFormatter extends NormalizerFormatter
{
const V0 = 0;
const V1 = 1;
@@ -46,7 +45,7 @@ class LogstashFormatter extends NormalizerFormatter
protected $contextPrefix;
/**
* @var integer LogStash format version to use
* @var integer logstash format version to use
*/
protected $version;
@@ -58,15 +57,13 @@ class LogstashFormatter extends NormalizerFormatter
*/
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');
$this->systemName = $systemName ?: gethostname();
$this->applicationName = $applicationName;
$this->extraPrefix = $extraPrefix;
$this->contextPrefix = $contextPrefix;
$this->version = $version;
}
@@ -77,14 +74,10 @@ class LogstashFormatter extends NormalizerFormatter
{
$record = parent::format($record);
switch ($this->version) {
case self::V1:
$message = $this->formatV1($record);
break;
case self::V0:
default:
$message = $this->formatV0($record);
break;
if ($this->version === self::V1) {
$message = $this->formatV1($record);
} else {
$message = $this->formatV0($record);
}
return $this->toJson($message) . "\n";

View File

@@ -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
* handler's constructor, by providing the appname in its context.
*
* @param array $context
* @param array $context
* @return null|string
*/
protected function getAppName(array $context)

View File

@@ -158,7 +158,6 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('app', $message['@type']);
}
/**
* @covers Monolog\Formatter\LogstashFormatter::format
*/