mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-01 19:00:20 +02:00
Fix JSON formatting of resource type, closes #1410
This commit is contained in:
@@ -165,6 +165,10 @@ class JsonFormatter extends NormalizerFormatter
|
||||
return $this->normalizeException($data);
|
||||
}
|
||||
|
||||
if (is_resource($data)) {
|
||||
return parent::normalize($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@@ -114,6 +114,14 @@ class JsonFormatterTest extends TestCase
|
||||
$this->assertContextContainsFormattedException($formattedThrowable, $message);
|
||||
}
|
||||
|
||||
public function testDefFormatWithResource()
|
||||
{
|
||||
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
|
||||
$record = $this->getRecord();
|
||||
$record['context'] = array('field_resource' => curl_init());
|
||||
$this->assertEquals('{"message":"test","context":{"field_resource":"[resource] (curl)"},"level":300,"level_name":"WARNING","channel":"test","datetime":'.json_encode($record['datetime']).',"extra":[]}', $formatter->format($record));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expected
|
||||
* @param string $actual
|
||||
|
Reference in New Issue
Block a user