php-epp2 icon indicating copy to clipboard operation
php-epp2 copied to clipboard

XML request/response logger

Open jbarbede opened this issue 10 years ago • 3 comments

Currently, with debug mode, you echo any XML send request/received response and it is already a great help.

We used to log these XML requests and responses in a database. It is really useful when a command failed and we can't exactly determine why (API response sometimes are not really clear). Like that, we can find a request and its response and send it to the API support.

Maybe we should be able to configure a logger when creating a Client object.

jbarbede avatar Apr 25 '15 18:04 jbarbede

Yes that would be a great idea, basically I would suggest to implement something via monolog and fallback to "echo" - so it would basically be a composer-suggests/recommends instead of requirement.

lifeofguenter avatar Apr 25 '15 18:04 lifeofguenter

Ok this might be a little more complicated:

  • the reason I implemented (rather shitty) the "log" method is so I can output each byte as soon as it arrives - this is so I can really see everything until to the point of a crash
  • implementing a logger means I would have to call the logger after I received all bytes (which might not work on a crash) and to make it have more sense it would have to add some useful information, like "what command was actually being made" - "what was the actual received xml data"

So conclusion:

  • logger will be a config option (psr-log interface)
  • it is independent of the current debug
  • it will additionally log the Frame class name that was sent

lifeofguenter avatar Apr 25 '15 19:04 lifeofguenter

We used to log also the command type (the Frame class in this case) so the whole conclusion sounds perfect.

jbarbede avatar Apr 25 '15 19:04 jbarbede