Skip to content

Commit 6f0091e

Browse files
Merge pull request #16 from liam-wiltshire/svenluijten-patch-1
Svenluijten patch 1
2 parents 069db15 + 1b6512c commit 6f0091e

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/Concerns/AutoloadsRelationships.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ private function logAutoload(string $relationship)
9191
$this->getLogDriver();
9292

9393
$file = $stack['file'];
94-
$lineNo = $stack['line'];
95-
96-
$blade = $this->getBlade($file);
97-
98-
$this->logDriver->info("[LARAVEL-JIT-LOADER] Relationship ". static::class."::{$relationship} was JIT-loaded."
99-
." Called in {$file} on line {$lineNo}" . ($blade ? " view: {$blade})" : ""));
94+
95+
$this->logDriver->info(
96+
'[LARAVEL-JIT-LOADER] Relationship '.static::class.'::'.$relationship.' was JIT-loaded.',
97+
[
98+
'relationship' => static::class.'::'.$relationship,
99+
'file' => $file,
100+
'line' => $stack['line'],
101+
'view' => $this->getBlade($file),
102+
]
103+
);
100104
}
101105

102106
/**

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)