mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 06:06:40 +02:00
Fix microseconds support on 7.1, and enable it by default as 7.1 has no perf cost anymore
This commit is contained in:
@@ -551,7 +551,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
* @covers Monolog\Logger::useMicrosecondTimestamps
|
||||
* @covers Monolog\Logger::addRecord
|
||||
*/
|
||||
public function testUseMicrosecondTimestamps($micro, $assert)
|
||||
public function testUseMicrosecondTimestamps($micro, $assert, $assertFormat)
|
||||
{
|
||||
$logger = new Logger('foo');
|
||||
$logger->useMicrosecondTimestamps($micro);
|
||||
@@ -560,14 +560,16 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
$logger->info('test');
|
||||
list($record) = $handler->getRecords();
|
||||
$this->{$assert}('000000', $record['datetime']->format('u'));
|
||||
$this->assertSame($record['datetime']->format($assertFormat), (string) $record['datetime']);
|
||||
}
|
||||
|
||||
public function useMicrosecondTimestampsProvider()
|
||||
{
|
||||
return [
|
||||
// this has a very small chance of a false negative (1/10^6)
|
||||
'with microseconds' => [true, 'assertNotSame'],
|
||||
'without microseconds' => [false, 'assertSame'],
|
||||
'with microseconds' => [true, 'assertNotSame', 'Y-m-d\TH:i:s.uP'],
|
||||
// php 7.1 always includes microseconds, so we keep them in, but we format the datetime without
|
||||
'without microseconds' => [false, PHP_VERSION_ID >= 70100 ? 'assertNotSame' : 'assertSame', 'Y-m-d\TH:i:sP'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user