mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[GH-ISSUE #1603] Why is includeStacktraces an option that cannot be set in constructor? #683
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#683
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rajyan on GitHub (Oct 9, 2021).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1603
Monolog version 2
Thank you for this great logging tool!
I wanted to ask,
Why is includeStacktraces an option that cannot be set in constructor in LineFormatter and JsonFormatter?
because we have to call
includeStacktraces()to enable stacktrace, we need to create an custom formatter just to enable stacktrace in some frameworks.ex.
using JsonFormatter with Laravel
github.com/laravel/framework@b0ae2123b1/src/Illuminate/Log/LogManager.php (L424-L426)https://github.com/contributte/monolog
note.
github.com/symfony/monolog-bundle@92bd02cc10/MonologBundle.php (L43-L52)If includeStacktraces could be set in constructor, we don't need to create a custom formatter class for these usages and configure it in framework config files.
@juan-morales commented on GitHub (Oct 22, 2021):
Thanks to this issue I found that the code needs to be refactor (IMO). I Will create a PR sometime this Week End or next week... and let you know also
@juan-morales commented on GitHub (Oct 26, 2021):
I honestly dont see like a big benefit of adding this parameter in the constructor.
I am thinking that maybe, the method
includeStacktracescan returnself, so for the laravel code snippet could look like:But still, dont see the benefit.
Also, in
LineFormatterthe constructor accepts parameters that are overwritten by calling methodincludeStacktraces()... so, just adding this parameter in the constructor will not be semantically correct.I would like to know someone else opinion on this one.
@Seldaek commented on GitHub (Mar 13, 2022):
I think it could be added. It would still implicitly force allowInlineLineBreaks to true in LineFormatter but that can be documented (and possibly throw if allowInlineLineBreaks=false is passed with includeStacktraces=true)
@rajyan commented on GitHub (Mar 14, 2022):
@Seldaek
Thanks for your response and fixes!