Skip to content

Created a SoapClient Processor#331

Closed
garadox wants to merge 7 commits intoSeldaek:masterfrom
tests-always-included:master
Closed

Created a SoapClient Processor#331
garadox wants to merge 7 commits intoSeldaek:masterfrom
tests-always-included:master

Conversation

@garadox
Copy link
Copy Markdown

@garadox garadox commented Mar 6, 2014

I had a need to log a formatted SOAP request and response with Monolog. For security purposes I also need to sanitize some elements of the request and response.

I created a Processor for the SoapClient, but due to the SoapClient not being available globally I'm expecting the variable in the context array of the record. This is the part I like the least - if you have a recommendation for making this better i'll implement it.

@stof
Copy link
Copy Markdown
Contributor

stof commented Mar 6, 2014

I don't understand the goal of this processor

@garadox
Copy link
Copy Markdown
Author

garadox commented Mar 6, 2014

The goal is twofold:

  • To obtain the XML for a SOAP request / response centrally for logging
  • To apply any provided XPath rules to the XML for sanitizing sensitive elements before being logged.

@stof
Copy link
Copy Markdown
Contributor

stof commented Mar 6, 2014

The first case is not something which should be solved by a processor in the logger, but by a logger inside the SOAP client.
A processor is about adding extra information in all messages (this info being extracted from other source than the calling code generally, like the memory usage or a request token). Your implementation is weird: it adds the SOAP request and response inside other log messages. If there is no log calls, the request will not be logged. And it will not be logged for itself.

A simple way to implement the logging of request and response is to extend the SoapClient as described in http://stackoverflow.com/a/1729614
In such implementation, Monolog (or even better any PSR-3 logger) would be used inside the implementation of _logRequest and _logResponse (and these methods would perform the sanitizing logic)

@Seldaek
Copy link
Copy Markdown
Owner

Seldaek commented Mar 7, 2014

Thanks for the pull request but I don't really feel like this is general purpose enough to warrant inclusion in monolog. @stof's feedback is also relevant in that a Processor might not really be the right way to do this, but it's probably technically working as is so feel free to keep this approach if you want in your project. I just don't see a need to include this in monolog.

@Seldaek Seldaek closed this Mar 7, 2014
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.

3 participants