Skip to content

fix: Logger - allow variable {line} to be used without variable {file} when logging message#9502

Merged
michalsn merged 3 commits intocodeigniter4:developfrom
michalsn:fix/logger
Apr 8, 2025
Merged

fix: Logger - allow variable {line} to be used without variable {file} when logging message#9502
michalsn merged 3 commits intocodeigniter4:developfrom
michalsn:fix/logger

Conversation

@michalsn
Copy link
Member

@michalsn michalsn commented Apr 3, 2025

Description
This PR fixes a bug where the {line} variable in the Logger cannot be used without specifying the {file} variable in the logged message.

Fixes #9501

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide


$logs = TestHandler::getLogs();

$this->assertGreaterThan(1, strpos($logs[0], $expected));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No?

Suggested change
$this->assertGreaterThan(1, strpos($logs[0], $expected));
$this->assertTrue(str_contains($logs[0], $expected));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can also write it this way, but I wanted to use the same style as in the previous test. This will ensure that the correct text is added to the log message. The logged message should not start with the $expected string.

@michalsn michalsn merged commit 6fbf601 into codeigniter4:develop Apr 8, 2025
50 checks passed
@michalsn michalsn deleted the fix/logger branch April 16, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Logger variable {line} cannot be use without variable {file}

3 participants