@@ -1,25 +1,26 @@
language: php
sudo: false
-dist: trusty
-
-php:
- - 7.2
- - 7.3
- - 7.4
- - nightly
cache:
directories:
- $HOME/.composer/cache
matrix:
- include:
- - php: 7.2
- env: deps=low
- fast_finish: true
- allow_failures:
- - php: nightly
+ fast_finish: true
+ include:
+ - php: 7.2
+ dist: bionic
+ - php: 7.3
+ - php: 7.4
+ - php: nightly
+ env: deps=low
+ allow_failures:
before_script:
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
@@ -157,6 +157,10 @@ class JsonFormatter extends NormalizerFormatter
return $this->normalizeException($data, $depth);
}
+ if (is_resource($data)) {
+ return parent::normalize($data);
+ }
+
return $data;
@@ -71,7 +71,8 @@ class RedisHandler extends AbstractProcessingHandler
protected function writeCapped(array $record): void
{
if ($this->redisClient instanceof \Redis) {
- $this->redisClient->multi()
+ $mode = defined('\Redis::MULTI') ? \Redis::MULTI : 1;
+ $this->redisClient->multi($mode)
->rpush($this->redisKey, $record["formatted"])
->ltrim($this->redisKey, -$this->capSize, -1)
->exec();
@@ -185,6 +185,14 @@ class JsonFormatterTest extends TestCase
);
+ public function testDefFormatWithResource()
+ {
+ $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
+ $record = $this->getRecord();
+ $record['context'] = ['field_resource' => curl_init()];
+ $this->assertEquals('{"message":"test","context":{"field_resource":"[resource(curl)]"},"level":300,"level_name":"WARNING","channel":"test","datetime":"'.$record['datetime']->format('Y-m-d\TH:i:s.uP').'","extra":{}}', $formatter->format($record));
/**
* @param string $expected
* @param string $actual