Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Method/Route logging in exceptionHandler() #8108

Merged
merged 1 commit into from
Oct 29, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Oct 27, 2023

Description
See https://forum.codeigniter.com/showthread.php?tid=88724&pid=413505#pid413505

  • add HTTP method and Route in Exception logging

E.g.,

CRITICAL - 2023-10-27 21:16:26 --> Allowed memory size of 8388608 bytes exhausted (tried to allocate 20971552 bytes)
[Method: GET, Route: /]
in APPPATH/Controllers/Home.php on line 9.
 1 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
CRITICAL - 2023-10-27 21:16:49 --> Allowed memory size of 8388608 bytes exhausted (tried to allocate 20971552 bytes)
[Method: GET, Route: test]
in APPPATH/Controllers/Home.php on line 9.
 1 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
CRITICAL - 2023-10-27 23:23:20 --> Allowed memory size of 8388608 bytes exhausted (tried to allocate 10485792 bytes)
[Method: CLI, Route: app:sample]
in APPPATH/Commands/Sample.php on line 59.
 1 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()

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

@kenjis kenjis added enhancement PRs that improve existing functionalities 4.5 labels Oct 27, 2023
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

This is a cool and helpful feature but it introduces an error-handling dependency on our Request service which (generally speaking) seems like a bad idea. I see you've already handled some potential niche cases, like CLI, but I would like hear thoughts from more of the team.

On closer inspection, this dependency already exists and you barely moved it earlier in the code. 🤦‍♂️ Don't mind me. Definitely a handy feature, let's go.

@kenjis
Copy link
Member Author

kenjis commented Oct 29, 2023

@MGatner It is a good view point. We should avoid unneeded dependencies.
However, I think it is acceptable for the exception handler dependency on Request.

@kenjis kenjis merged commit a4127ca into codeigniter4:4.5 Oct 29, 2023
44 checks passed
@kenjis kenjis deleted the feat-route-logging-in-exception branch October 29, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.5 enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants