Skip to content

Commit 1cfa5fa

Browse files
Improve logging
1 parent 69a7b78 commit 1cfa5fa

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Concerns/AutoloadsRelationships.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function logAutoload(string $relationship)
9292

9393
$file = $stack['file'];
9494

95-
$this->logDriver->info('[LARAVEL-JIT-LOADER] Relationship was JIT-loaded.', [
95+
$this->logDriver->info('[LARAVEL-JIT-LOADER] Relationship '.static::class.'::'.$relationship.' was JIT-loaded.', [
9696
'relationship' => static::class.'::'.$relationship,
9797
'file' => $file,
9898
'line' => $stack['line'],

tests/Concerns/AutoloadsRelationshipsTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ public function testGetRelationshipFromMethodUnderThresholdDoesAutoLoad()
5151

5252
public function testGetRelationshipFromMethodUnderThresholdDoesAutoLoadWithLogging()
5353
{
54-
$message = "[LARAVEL-JIT-LOADER] Relationship " . TraitModel::class . "::myRelationship was JIT-loaded. Called in " . __FILE__ . " on line " . (__LINE__ + 12);
54+
$message = "[LARAVEL-JIT-LOADER] Relationship " . TraitModel::class . "::myRelationship was JIT-loaded.";
55+
$context = [
56+
'relationship' => TraitModel::class.'::myRelationship',
57+
'file' => __FILE__,
58+
'line' => __LINE__ + 14,
59+
'view' => false,
60+
];
5561

5662
$driver = $this->getMockBuilder(LoggerInterface::class)->getMock();
5763
$driver
5864
->expects($this->atLeastOnce())
5965
->method('info')
60-
->with($message)
66+
->with($message, $context)
6167
->willReturn(true);
6268

6369
$models = TraitModel::all();

0 commit comments

Comments
 (0)