1
0
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:
Jordi Boggiano
2016-11-14 11:53:15 +01:00
parent 9691bde77a
commit 4a43d9b17c
4 changed files with 16 additions and 8 deletions

View File

@@ -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'],
];
}
}