Skip to content

Commit 7e609c1

Browse files
authored
Merge pull request #21 from smalex86/develop
Correcting depth of backtrace in CachedFileRoute
2 parents 5228cc4 + 36a54c6 commit 7e609c1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Route.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,14 @@ protected function getStatusWord(int $level): string {
144144

145145
/**
146146
* Get file and line from stacktrace in array view
147+
* @param int $depth depth of backtrace
147148
* @return array
148149
*/
149-
protected function getFileLine(): array {
150+
protected function getFileLine(int $depth = 3): array {
150151
$dbt = debug_backtrace();
151-
if (isset($dbt[3])) {
152-
$result['file'] = $dbt[3]['file'];
153-
$result['line'] = $dbt[3]['line'];
152+
if (isset($dbt[$depth])) {
153+
$result['file'] = $dbt[$depth]['file'];
154+
$result['line'] = $dbt[$depth]['line'];
154155
}
155156
return $result;
156157
}

src/route/CachedFileRoute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function log($level, $message, array $context = []): bool
103103
protected function getLogLine($level, $message, array $context = array()): string
104104
{
105105
// pull file and line
106-
$fileLine = $this->getFileLine();
106+
$fileLine = $this->getFileLine(4);
107107
// generate log line
108108
return trim(strtr($this->template, [
109109
'{date}' => $this->getDate(),

0 commit comments

Comments
 (0)