I am creating a module to capture response on controller_front_send_response_before
event.
In my observer file, I am getting both request
and response
object but I am not able to locate below class of response
object:
Magento\Framework\App\Response\Http\Interceptor
I am searching in /magento root/vendor/magento/framework/App
directory.
Also, When I was trying to log response, I got only headers in log file. How can I get final content that will print on browser?
In onbserver file I have written following code:
Ktpl\Logresponse\Observer\Response\Capture.php
namespace Ktpl\Logresponse\Observer\Response;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
class Capture implements ObserverInterface
{
private $logger;
public function __construct(\Psr\Log\LoggerInterface $logger) {
$this->logger = $logger;
}
public function execute(Observer $observer) {
try {
$response = $observer->getEvent()->getData('response');
$this->logger->debug($response);
$this->logger->debug(get_class($response));
} catch(\Exception $e) {
$this->logger->critical($e);
}
}
}
Please share if anyone has any idea about this.
Magento\Framework\App\Response\Http\Interceptor
and I'm not able to locate this class.