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

Optional debug logging #173

Merged
merged 5 commits into from Feb 15, 2023
Merged

Optional debug logging #173

merged 5 commits into from Feb 15, 2023

Conversation

4c0n
Copy link
Contributor

@4c0n 4c0n commented Jan 3, 2022

Finding out what is going wrong in prod environments can be tricky sometimes.
This PR allows an optional logger to be passed which enables a debug log.

Now finding out what's happening is a breeze.

@rijnhard
Copy link

Seriously the amount of hours I'm spending on debugging this... can this please be merged?

@Seldaek Seldaek merged commit b111f4b into nelmio:master Feb 15, 2023
@Seldaek
Copy link
Member

Seldaek commented Feb 15, 2023

Thanks - makes sense. I'd appreciate if anyone has time to send a README PR to add an example of how this can be configured to get logging enable though

@NikoGrano
Copy link

I can see this being a really useful feature and just found it out via changelog. However, when something ain't documented, nobody is using it.

Currently, I am "reverse engineering" this feature to get it working...

@4c0n Would you mind to share us how you intended this feature to be used?

@4c0n
Copy link
Contributor Author

4c0n commented Mar 26, 2023

I can see this being a really useful feature and just found it out via changelog. However, when something ain't documented, nobody is using it.

Currently, I am "reverse engineering" this feature to get it working...

@4c0n Would you mind to share us how you intended this feature to be used?

It's really easy, you override the service of the bundle and have your logger service injected.

@NikoGrano
Copy link

This is the approach I did, however, it is vulnerable to any BC changes. A better approach would be having the option to set logger in the configuration of the bundle. I totally understand if you are lacking time to implement it.

When possible, would you mind still documenting this?

In addition to this, adding logging also here, wouldn't hurt. For example, I had a case where one of the required headers wasn't allowed.

if (!in_array($header, $options['allow_headers'], true)) {
$sanitizedMessage = htmlentities('Unauthorized header '.$header, ENT_QUOTES, 'UTF-8');
$response->setStatusCode(400);
$response->setContent($sanitizedMessage);
break;

@4c0n
Copy link
Contributor Author

4c0n commented Mar 26, 2023

This is the approach I did, however, it is vulnerable to any BC changes. A better approach would be having the option to set logger in the configuration of the bundle. I totally understand if you are lacking time to implement it.

When possible, would you mind still documenting this?

In addition to this, adding logging also here, wouldn't hurt. For example, I had a case where one of the required headers wasn't allowed.

if (!in_array($header, $options['allow_headers'], true)) {
$sanitizedMessage = htmlentities('Unauthorized header '.$header, ENT_QUOTES, 'UTF-8');
$response->setStatusCode(400);
$response->setContent($sanitizedMessage);
break;

BC changes should be in new major versions only, in which case you should review if your setup is compatible with the new version regardless.
I don't use this bundle anymore and I would suggest that you contribute the changes you envision yourself. I contributed this, because for me these changes were sufficient to solve the issues I was facing, however I had to use a fork and go through a lot more effort than I would have wished to find out what exactly was happening.
Mind you it took a really long time before this was merged and I have lost interest in the meantime.

@4c0n 4c0n deleted the logging branch March 28, 2023 07:31
@Seldaek
Copy link
Member

Seldaek commented Jan 18, 2024

See #197 for docs for now.. But if anyone wants to improve this with docs or ideally a config option to enable logging that'd be great.

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.

None yet

4 participants