mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 04:37:38 +02:00
Switch to DateTimeImmutable everywhere
This commit is contained in:
@@ -37,7 +37,7 @@ class LogglyFormatter extends JsonFormatter
|
||||
*/
|
||||
public function format(array $record)
|
||||
{
|
||||
if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) {
|
||||
if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTimeInterface)) {
|
||||
$record["timestamp"] = $record["datetime"]->format("Y-m-d\TH:i:s.uO");
|
||||
unset($record["datetime"]);
|
||||
}
|
||||
|
@@ -85,7 +85,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
if ($data instanceof \DateTime) {
|
||||
if ($data instanceof \DateTimeInterface) {
|
||||
return $data->format($this->dateFormat);
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
|
||||
protected function normalize($data)
|
||||
{
|
||||
if (is_object($data) && !$data instanceof \DateTime) {
|
||||
if (is_object($data) && !$data instanceof \DateTimeInterface) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@@ -146,7 +146,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'monolog',
|
||||
'datetime' => new \DateTime(),
|
||||
'datetime' => new \DateTimeImmutable(),
|
||||
'extra' => array(),
|
||||
);
|
||||
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
|
||||
|
@@ -48,7 +48,7 @@ class RotatingFileHandler extends StreamHandler
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->maxFiles = (int) $maxFiles;
|
||||
$this->nextRotation = new \DateTime('tomorrow');
|
||||
$this->nextRotation = new \DateTimeImmutable('tomorrow');
|
||||
$this->filenameFormat = '{filename}-{date}';
|
||||
$this->dateFormat = 'Y-m-d';
|
||||
|
||||
@@ -112,7 +112,7 @@ class RotatingFileHandler extends StreamHandler
|
||||
{
|
||||
// update filename
|
||||
$this->url = $this->getTimedFilename();
|
||||
$this->nextRotation = new \DateTime('tomorrow');
|
||||
$this->nextRotation = new \DateTimeImmutable('tomorrow');
|
||||
|
||||
// skip GC of old logs if files are unlimited
|
||||
if (0 === $this->maxFiles) {
|
||||
|
@@ -316,9 +316,9 @@ class Logger implements LoggerInterface
|
||||
}
|
||||
|
||||
if ($this->microsecondTimestamps) {
|
||||
$ts = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), $this->timezone);
|
||||
$ts = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', microtime(true)), $this->timezone);
|
||||
} else {
|
||||
$ts = new \DateTime('', $this->timezone);
|
||||
$ts = new \DateTimeImmutable('', $this->timezone);
|
||||
}
|
||||
$ts->setTimezone($this->timezone);
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||
'level' => $level,
|
||||
'level_name' => Logger::getLevelName($level),
|
||||
'channel' => 'test',
|
||||
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
|
||||
'datetime' => \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
|
||||
'extra' => array(),
|
||||
);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('ip' => '127.0.0.1'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -59,7 +59,7 @@ class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'CRITICAL',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -92,7 +92,7 @@ class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'DEBUG',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -122,7 +122,7 @@ class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'INFO',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
),
|
||||
@@ -131,7 +131,7 @@ class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'WARNING',
|
||||
'channel' => 'foo',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log2',
|
||||
),
|
||||
|
@@ -35,7 +35,7 @@ class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
|
@@ -36,7 +36,7 @@ class FluentdFormatterTest extends TestCase
|
||||
public function testFormat()
|
||||
{
|
||||
$record = $this->getRecord(Logger::WARNING);
|
||||
$record['datetime'] = new \DateTime("@0");
|
||||
$record['datetime'] = new \DateTimeImmutable("@0");
|
||||
|
||||
$formatter = new FluentdFormatter();
|
||||
$this->assertEquals(
|
||||
@@ -51,7 +51,7 @@ class FluentdFormatterTest extends TestCase
|
||||
public function testFormatWithTag()
|
||||
{
|
||||
$record = $this->getRecord(Logger::ERROR);
|
||||
$record['datetime'] = new \DateTime("@0");
|
||||
$record['datetime'] = new \DateTimeImmutable("@0");
|
||||
|
||||
$formatter = new FluentdFormatter(true);
|
||||
$this->assertEquals(
|
||||
|
@@ -33,7 +33,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -68,7 +68,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('file' => 'test', 'line' => 14),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -106,7 +106,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('key' => 'pair'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -147,7 +147,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'file' => '/some/file/in/dir.php:56',
|
||||
'trace' => array('/some/file/1.php:23', '/some/file/2.php:3'),
|
||||
)),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -171,7 +171,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('key' => 'pair'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -205,7 +205,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('exception' => str_repeat(' ', 32767)),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('key' => str_repeat(' ', 32767)),
|
||||
'message' => 'log'
|
||||
);
|
||||
|
@@ -84,7 +84,7 @@ class JsonFormatterTest extends TestCase
|
||||
'level_name' => 'CRITICAL',
|
||||
'channel' => 'core',
|
||||
'context' => array('exception' => $exception),
|
||||
'datetime' => new \DateTime(),
|
||||
'datetime' => new \DateTimeImmutable(),
|
||||
'extra' => array(),
|
||||
'message' => 'foobar',
|
||||
));
|
||||
@@ -94,7 +94,7 @@ class JsonFormatterTest extends TestCase
|
||||
} else {
|
||||
$path = substr(json_encode($exception->getFile()), 1, -1);
|
||||
}
|
||||
$this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"'.$exception->getMessage().'","code":'.$exception->getCode().',"file":"'.$path.':'.$exception->getLine().'"}},"datetime":'.json_encode(new \DateTime()).',"extra":[],"message":"foobar"}'."\n", $message);
|
||||
$this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"'.$exception->getMessage().'","code":'.$exception->getCode().',"file":"'.$path.':'.$exception->getLine().'"}},"datetime":'.json_encode(new \DateTimeImmutable()).',"extra":[],"message":"foobar"}'."\n", $message);
|
||||
}
|
||||
|
||||
public function testDefFormatWithPreviousException()
|
||||
@@ -105,7 +105,7 @@ class JsonFormatterTest extends TestCase
|
||||
'level_name' => 'CRITICAL',
|
||||
'channel' => 'core',
|
||||
'context' => array('exception' => $exception),
|
||||
'datetime' => new \DateTime(),
|
||||
'datetime' => new \DateTimeImmutable(),
|
||||
'extra' => array(),
|
||||
'message' => 'foobar',
|
||||
));
|
||||
@@ -117,6 +117,6 @@ class JsonFormatterTest extends TestCase
|
||||
$pathPrevious = substr(json_encode($exception->getPrevious()->getFile()), 1, -1);
|
||||
$pathException = substr(json_encode($exception->getFile()), 1, -1);
|
||||
}
|
||||
$this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"'.$exception->getMessage().'","code":'.$exception->getCode().',"file":"'.$pathException.':'.$exception->getLine().'","previous":{"class":"LogicException","message":"'.$exception->getPrevious()->getMessage().'","code":'.$exception->getPrevious()->getCode().',"file":"'.$pathPrevious.':'.$exception->getPrevious()->getLine().'"}}},"datetime":'.json_encode(new \DateTime()).',"extra":[],"message":"foobar"}'."\n", $message);
|
||||
$this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"'.$exception->getMessage().'","code":'.$exception->getCode().',"file":"'.$pathException.':'.$exception->getLine().'","previous":{"class":"LogicException","message":"'.$exception->getPrevious()->getMessage().'","code":'.$exception->getPrevious()->getCode().',"file":"'.$pathPrevious.':'.$exception->getPrevious()->getLine().'"}}},"datetime":'.json_encode(new \DateTimeImmutable()).',"extra":[],"message":"foobar"}'."\n", $message);
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'channel' => 'log',
|
||||
'context' => array(),
|
||||
'message' => 'foo',
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
));
|
||||
$this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
|
||||
@@ -37,7 +37,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'message' => 'foo',
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
'context' => array(
|
||||
'foo' => 'bar',
|
||||
@@ -56,7 +56,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array('ip' => '127.0.0.1'),
|
||||
'message' => 'log',
|
||||
));
|
||||
@@ -70,7 +70,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array('ip' => '127.0.0.1', 'file' => 'test'),
|
||||
'message' => 'log',
|
||||
));
|
||||
@@ -84,7 +84,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
));
|
||||
@@ -98,7 +98,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('foo' => 'bar'),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array('foo' => 'xbar'),
|
||||
'message' => 'log',
|
||||
));
|
||||
@@ -112,7 +112,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
||||
'message' => 'foobar',
|
||||
));
|
||||
@@ -127,7 +127,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'CRITICAL',
|
||||
'channel' => 'core',
|
||||
'context' => array('exception' => new \RuntimeException('Foo')),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
'message' => 'foobar',
|
||||
));
|
||||
@@ -145,7 +145,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'CRITICAL',
|
||||
'channel' => 'core',
|
||||
'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
'message' => 'foobar',
|
||||
));
|
||||
@@ -164,7 +164,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'channel' => 'test',
|
||||
'message' => 'bar',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
),
|
||||
array(
|
||||
@@ -172,7 +172,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'channel' => 'log',
|
||||
'message' => 'foo',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
),
|
||||
));
|
||||
|
@@ -36,6 +36,6 @@ class LogglyFormatterTest extends TestCase
|
||||
$formatted_decoded = json_decode($formatter->format($record), true);
|
||||
$this->assertArrayNotHasKey("datetime", $formatted_decoded);
|
||||
$this->assertArrayHasKey("timestamp", $formatted_decoded);
|
||||
$this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]);
|
||||
$this->assertEquals(new \DateTimeImmutable($formatted_decoded["timestamp"]), $record["datetime"]);
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -66,7 +66,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('file' => 'test', 'line' => 14),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -88,7 +88,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('key' => 'pair'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -117,7 +117,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('key' => 'pair'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -143,7 +143,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('key' => 'pair'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -162,7 +162,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => '¯\_(ツ)_/¯',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(
|
||||
'user_agent' => "\xD6WN; FBCR/OrangeEspa\xF1a; Vers\xE3o/4.0; F\xE4rist",
|
||||
),
|
||||
|
@@ -62,7 +62,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime('2016-01-21T21:11:30.123456+00:00'),
|
||||
'datetime' => new \DateTimeImmutable('2016-01-21T21:11:30.123456+00:00'),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
@@ -89,7 +89,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
$record = array(
|
||||
'message' => 'some log message',
|
||||
'context' => array(
|
||||
'stuff' => new \DateTime('1969-01-21T21:11:30.123456+00:00'),
|
||||
'stuff' => new \DateTimeImmutable('1969-01-21T21:11:30.123456+00:00'),
|
||||
'some_object' => $someObject,
|
||||
'context_string' => 'some string',
|
||||
'context_int' => 123456,
|
||||
@@ -98,7 +98,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime('2016-01-21T21:11:30.123456+00:00'),
|
||||
'datetime' => new \DateTimeImmutable('2016-01-21T21:11:30.123456+00:00'),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
@@ -145,7 +145,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime('2016-01-21T21:11:30.123456+00:00'),
|
||||
'datetime' => new \DateTimeImmutable('2016-01-21T21:11:30.123456+00:00'),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
@@ -181,7 +181,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime('2016-01-21T21:11:30.123456+00:00'),
|
||||
'datetime' => new \DateTimeImmutable('2016-01-21T21:11:30.123456+00:00'),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
@@ -220,7 +220,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime('2016-01-21T21:11:30.123456+00:00'),
|
||||
'datetime' => new \DateTimeImmutable('2016-01-21T21:11:30.123456+00:00'),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
@@ -249,7 +249,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime('2016-01-21T21:11:30.123456+00:00'),
|
||||
'datetime' => new \DateTimeImmutable('2016-01-21T21:11:30.123456+00:00'),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'message' => 'foo',
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
||||
'context' => array(
|
||||
'foo' => 'bar',
|
||||
@@ -103,7 +103,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'channel' => 'test',
|
||||
'message' => 'bar',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
),
|
||||
array(
|
||||
@@ -111,7 +111,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'channel' => 'log',
|
||||
'message' => 'foo',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime,
|
||||
'datetime' => new \DateTimeImmutable,
|
||||
'extra' => array(),
|
||||
),
|
||||
));
|
||||
|
@@ -49,7 +49,7 @@ class ScalarFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'baz' => false,
|
||||
'bam' => array(1, 2, 3),
|
||||
'bat' => array('foo' => 'bar'),
|
||||
'bap' => \DateTime::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'),
|
||||
'bap' => \DateTimeImmutable::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'),
|
||||
'ban' => $exception,
|
||||
));
|
||||
|
||||
|
@@ -26,7 +26,7 @@ class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('ip' => '127.0.0.1'),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -51,7 +51,7 @@ class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('from' => 'logger'),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -76,7 +76,7 @@ class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -101,7 +101,7 @@ class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array(),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -127,7 +127,7 @@ class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
array('bar1', 'bar2', 'bar3'),
|
||||
),
|
||||
),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'table-message',
|
||||
);
|
||||
|
@@ -88,10 +88,10 @@ class DeduplicationHandlerTest extends TestCase
|
||||
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
|
||||
|
||||
$record = $this->getRecord(Logger::ERROR);
|
||||
$record['datetime']->modify('+62seconds');
|
||||
$record['datetime'] = $record['datetime']->modify('+62seconds');
|
||||
$handler->handle($record);
|
||||
$record = $this->getRecord(Logger::CRITICAL);
|
||||
$record['datetime']->modify('+62seconds');
|
||||
$record['datetime'] = $record['datetime']->modify('+62seconds');
|
||||
$handler->handle($record);
|
||||
|
||||
$handler->flush();
|
||||
@@ -115,13 +115,13 @@ class DeduplicationHandlerTest extends TestCase
|
||||
|
||||
// handle two records from yesterday, and one recent
|
||||
$record = $this->getRecord(Logger::ERROR);
|
||||
$record['datetime']->modify('-1day -10seconds');
|
||||
$record['datetime'] = $record['datetime']->modify('-1day -10seconds');
|
||||
$handler->handle($record);
|
||||
$record2 = $this->getRecord(Logger::CRITICAL);
|
||||
$record2['datetime']->modify('-1day -10seconds');
|
||||
$record2['datetime'] = $record2['datetime']->modify('-1day -10seconds');
|
||||
$handler->handle($record2);
|
||||
$record3 = $this->getRecord(Logger::CRITICAL);
|
||||
$record3['datetime']->modify('-30seconds');
|
||||
$record3['datetime'] = $record3['datetime']->modify('-30seconds');
|
||||
$handler->handle($record3);
|
||||
|
||||
// log is written as none of them are duplicate
|
||||
|
@@ -62,7 +62,7 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
@@ -167,7 +167,7 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'message' => 'log',
|
||||
);
|
||||
|
@@ -62,7 +62,7 @@ class FleepHookHandlerTest extends TestCase
|
||||
'level' => Logger::DEBUG,
|
||||
'level_name' => Logger::getLevelName(Logger::DEBUG),
|
||||
'channel' => 'channel',
|
||||
'datetime' => new \DateTime(),
|
||||
'datetime' => new \DateTimeImmutable(),
|
||||
'extra' => array(),
|
||||
);
|
||||
|
||||
|
@@ -171,29 +171,29 @@ class HipChatHandlerTest extends TestCase
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
'red',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
'yellow',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
'green',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
|
||||
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
'gray',
|
||||
),
|
||||
|
Reference in New Issue
Block a user