diff --git a/.gitignore b/.gitignore index c12138b..033e21f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ powatag/.yo-rc.json powatag/config.xml config*.xml +logs.txt diff --git a/api/v1/PowaTagAPIAbstract.php b/api/v1/PowaTagAPIAbstract.php index 59fcd1d..a631a2a 100644 --- a/api/v1/PowaTagAPIAbstract.php +++ b/api/v1/PowaTagAPIAbstract.php @@ -25,6 +25,8 @@ * International Registered Trademark & Property of PrestaShop SA */ +require_once(dirname(__FILE__).'/../../classes/PowaTagRequestLogs.php'); + abstract class PowaTagAPIAbstract { @@ -123,6 +125,15 @@ public function __construct($request) self::$api_log = Configuration::get('POWATAG_API_LOG'); self::$request_log = Configuration::get('POWATAG_REQUEST_LOG'); + + PowaTagRequestLogs::add(array( + 'args' => $this->args, + 'endpoint' => $this->endpoint, + 'verb' => $this->verb, + 'method' => $this->method, + 'data' => $this->data, + )); + $this->module = Module::getInstanceByName('powatag'); } @@ -151,6 +162,9 @@ protected function _response($data) $status = $this->getResponse(); header("HTTP/1.1 ".$status." ".$this->_requestStatus($status)); + PowaTagRequestLogs::add(array( + 'response' => Tools::jsonEncode($data) + )); return Tools::jsonEncode($data); } diff --git a/classes/PowaTagRequestLogs.php b/classes/PowaTagRequestLogs.php new file mode 100644 index 0000000..57be1c4 --- /dev/null +++ b/classes/PowaTagRequestLogs.php @@ -0,0 +1,40 @@ + +* @copyright 2007-2014 PrestaShop SA +* @version Release: $Revision: 7776 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class PowaTagRequestLogs { + + + static public function add($datas) + { + $handle = fopen(dirname(__FILE__).'/../logs_requests.txt', 'a+'); + fwrite($handle, print_r($datas, true)); + fclose($handle); + + } + + +} \ No newline at end of file