diff --git a/Transport/AuthenticationTokenTransportDecorator.php b/Transport/AuthenticationTokenTransportDecorator.php index d6925c4..3d6c7a5 100644 --- a/Transport/AuthenticationTokenTransportDecorator.php +++ b/Transport/AuthenticationTokenTransportDecorator.php @@ -1,10 +1,13 @@ transport->call($module, $method, $paramList); } -} \ No newline at end of file + + /** + * Sets a logger instance on the object. + * + * @param LoggerInterface $logger + * + * @return void + */ + public function setLogger(LoggerInterface $logger) + { + if ($this->transport instanceof LoggerAwareInterface) { + $this->transport->setLogger($logger); + } + } +} diff --git a/Transport/XmlDataTransportDecorator.php b/Transport/XmlDataTransportDecorator.php index 397d365..2cdd1c7 100644 --- a/Transport/XmlDataTransportDecorator.php +++ b/Transport/XmlDataTransportDecorator.php @@ -4,12 +4,14 @@ use Christiaan\ZohoCRMClient\Exception; use Christiaan\ZohoCRMClient\Response; use Christiaan\ZohoCRMClient\ZohoError; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerInterface; use SimpleXMLElement; /** * XmlDataTransportDecorator handles the XML communication with Zoho */ -class XmlDataTransportDecorator implements Transport +class XmlDataTransportDecorator implements Transport, LoggerAwareInterface { /** @var Transport */ private $transport; @@ -46,6 +48,20 @@ public function call($module, $method, array $paramList) return $this->parse($response); } + /** + * Sets a logger instance on the object. + * + * @param LoggerInterface $logger + * + * @return void + */ + public function setLogger(LoggerInterface $logger) + { + if ($this->transport instanceof LoggerAwareInterface) { + $this->transport->setLogger($logger); + } + } + /** * @param array $records * @throws \Christiaan\ZohoCRMClient\Exception\RuntimeException diff --git a/ZohoCRMClient.php b/ZohoCRMClient.php index 8a26695..296dae8 100644 --- a/ZohoCRMClient.php +++ b/ZohoCRMClient.php @@ -47,6 +47,10 @@ public function __construct($module, $authToken, $realm = 'com') public function setLogger(LoggerInterface $logger) { $this->logger = $logger; + + if ($this->transport instanceof LoggerAwareInterface) { + $this->transport->setLogger($logger); + } } /**