Mobile app version of vmapp.org
Login or Join
Chiappetta492

: How to debug a file called by 3rd party I have a script that is being called by a 3rd party script, but it doesn't work. I can see in the logs that the file is in fact being called,

@Chiappetta492

Posted in: #Debug #Php

I have a script that is being called by a 3rd party script, but it doesn't work. I can see in the logs that the file is in fact being called, just nothing happends.

How do you debug a file called by a 3rd party?


I can't call the file from the commandline / another file, due to security checks
The 3rd party is an automated process, I can not ask them for help
I do not know if the code works properly, doesn't do a thing, or it has an error


This is an older site (or consider a less pro website), proper errorhandling does not exist



Best solution thusfar:
Place a bunch of file_put_contents($loc.'/a-1.txt', '') (where the 1 increments every time used) and see how many files are created/updated when you let the script excecute.
This is slow, and only gives me how the code flows, not actual errors, so this isn't very efficient.

I've found some topics talking about changing STDIN, STDOUT and STDERR, but I can't seem to get those to work out of the box.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Chiappetta492

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

This is one of the absolute worst case scenarios when inhereting a web project that is old, poorly designed, badly documented, and can't easily be debugged. Any code at all let alone mission critical autonomous code like this should be well documented and have thorough error reporting. Assuming this has been done in a language like PHP you can increase the error logging level to informational which will show every last error message that may be generated by the server. This will report on any errors that are being handled by the language and not the code. The next step would be to go through the code and identify anywhere that the code outputs any data to the connection (assuming a http style connection any data that is effectively "printed" to the buffer for outputting) and add logging so all the data is logged to file. If you add each instance of data output to an array with details on the line it was generated at you can push all data to to a file one time during each request to the web service to minimise file writes causing delays and then read through what is being sent back to the bank.

It is going to be extremely difficult and complicated but there is not much more that can be done in the short term to identify the problem. In the long term you should absolutely be going through the code and implementing sanity checks, data validation, and error logging and reporting. Basically anything that will prevent the code from running should be logged in a manner that will let you go through and find out not just what the error was but what could have caused the error, the data being worked on, and what line the error occurred on.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme