Feature: Add debug logging option
Closed this issue ยท 6 comments
It would be nice, if there is an option to enable some debug logging (especially in combination with https://github.com/FLUX-SE/SyliusPayumStripePlugin
It would help during debugging, e.g. log all requests and responses from and to the stripe API. and some additional logging.
In theory this could be done by using Psr/LoggerInterface and provide a nulllogger as default, if not set by the sylius plugin or the symfony bundle.
Not sure how much effort it is to add it everywhere but it would definitely be helpful in some edge cases for debugging purposes? Maybe the api client from stripe could be extended to do so but not sure if that is possible (didn't check the stripe php code in too much detail).
@AndreasA this could be done with Stripe Cli very easily when you listen to all webhooks, or through the Stripe dashboard.
And yes I also think there is a way to log all Stripe request calls using what stripe/stripe-php
is providing.
Since I'm developing with Stripe API, I only needed the Stripe dashboard or the Stripe CLI. The rest can be done by xDebugging actions calls starting from the \Payum\Core\Gateway
class.
Hope it helps you ๐
@Prometee that helps locally, however, I am more interested in finding out how certain edge cases came to be (after the happened) on the production environment. There the CLI and XDebug isn't really possible, e.g. I created FLUX-SE/SyliusPayumStripePlugin#32 because I think this or something like this happened a few times (customer paid too often) on a production system, but I am not 100% sure if this was what happened or if it is something else or similar to that issue.
However, I think if the payment is invalidated in case the payment is new during after-pay
, all scenarios where a user pays multiple times for the same order shouldn't be possible anymore. So more logging might not be necessary anymore, but it could still be helpful if there are other edge cases as those are very often hard to reproduce too.
Which is way more logging for production environments would be really helpful.
@AndreasA I understand your point and your frustration, making a debug on prod env is never a good idea. You must retrieve the production data or a piece of it and make a step to step debug on your localhost env instead.
Thank to you we were able to found the root of this issue. Open Source projects like this one require time to clear all possible edge cases. Right now I think it was the most annoying issue dev's users can have with this Payum library and again thanks to you the issue is fixed.
I really think this Payum library needs some graphs to help devs like you finding what could go wrong or what can be possible with it. I'm not an expert doing graphs but I could try making some to explain how Stripe is working and how to play with it through the Payum library.
@Prometee Yes, debugging should only be done locally (if at all possible). However, in order to find out the steps to reproduce the issue locally, a log file on the production system about what happened would be really useful, as otherwise it is a lot of code analyzing and guessing what might have happened for the issue to occur.
It is also enough to optionally enable the logging, e.g. an issue just occured that one cannot reproduce, in the hope that it re-occurs for another user. The log file also does not need to be kept indefinitely - actually I strongly advice against that (also regarding privacy laws). These options would e.g. be available if monolog is used.
Having the log file to find out the necessary steps to reproduce an error can be really helpful and I don't mean to reproduce it on the production system but to know what to do locally to reproduce it.
But I also understand if you don't think it is necessary currently.
I checked it deeper and monolog (if you are using it) is already making logs for each action in a dev env. So making those same logs outputting during a prod env should be possible for the Payum part. The Stripe lib is another story but can be enabled too, but again the logs from Stripe dashboard is always enough
OK. I checked the stripe php library and there is a logger and logging possibility but from what I can see it only log three error messages and nothing else and there certainly is not debug option. But I guess that is actually more an issue with stripe php than your library ๐
and you are correct, there is already an option to log all actions in Payum that one just would need to enable. so I guess there is not really much logging that would be required by your library as it is either logged already by Payum or something that the stripe php api needs to log or available in the stripe dashboard.
The only issue with the dashboard might be missing permissions to access it, as in a production environment it might not necessarily an account one has access to, but if the corresponding customer wants it fixed, they will have to give the developer access to it, at least temporarily. ๐
Thanks for your feedback.