mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-20 11:51:32 +02:00
Add LogRecord class, drop PHP <8.1
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\LogRecord;
|
||||
|
||||
class ElasticaFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
@@ -30,18 +31,18 @@ class ElasticaFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
public function testFormat()
|
||||
{
|
||||
// test log message
|
||||
$msg = [
|
||||
'level' => Logger::ERROR,
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => ['foo' => 7, 'bar', 'class' => new \stdClass],
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => [],
|
||||
'message' => 'log',
|
||||
];
|
||||
$msg = new LogRecord(
|
||||
level: Logger::ERROR,
|
||||
levelName: 'ERROR',
|
||||
channel: 'meh',
|
||||
context: ['foo' => 7, 'bar', 'class' => new \stdClass],
|
||||
datetime: new \DateTimeImmutable("@0"),
|
||||
message: 'log',
|
||||
);
|
||||
|
||||
// expected values
|
||||
$expected = $msg;
|
||||
$expected = (array) $msg;
|
||||
unset($expected['formatted']);
|
||||
$expected['datetime'] = '1970-01-01T00:00:00.000000+00:00';
|
||||
$expected['context'] = [
|
||||
'class' => ['stdClass' => []],
|
||||
|
@@ -152,7 +152,7 @@ class LineFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
||||
|
||||
$this->assertRegexp('{^\['.date('Y-m-d').'] core\.CRITICAL: foobar \{"exception":"\[object] \(RuntimeException\(code: 0\): Foo at '.preg_quote(substr($path, 1, -1)).':'.(__LINE__ - 8).'\)\n\[stacktrace]\n#0}', $message);
|
||||
$this->assertMatchesRegularExpression('{^\['.date('Y-m-d').'] core\.CRITICAL: foobar \{"exception":"\[object] \(RuntimeException\(code: 0\): Foo at '.preg_quote(substr($path, 1, -1)).':'.(__LINE__ - 8).'\)\n\[stacktrace]\n#0}', $message);
|
||||
}
|
||||
|
||||
public function testDefFormatWithPreviousException()
|
||||
@@ -242,7 +242,7 @@ class LineFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertRegExp('/foo bar/', $message);
|
||||
$this->assertMatchesRegularExpression('/foo bar/', $message);
|
||||
}
|
||||
|
||||
public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet()
|
||||
@@ -256,7 +256,7 @@ class LineFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertRegExp('/foo\nbar/', $message);
|
||||
$this->assertMatchesRegularExpression('/foo\nbar/', $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user