diff --git a/lib/mvcfronk/mfBase/mfBaseApicontroller.php b/lib/mvcfronk/mfBase/mfBaseApicontroller.php index 9b517ea9f..508ea160e 100644 --- a/lib/mvcfronk/mfBase/mfBaseApicontroller.php +++ b/lib/mvcfronk/mfBase/mfBaseApicontroller.php @@ -5,6 +5,7 @@ include_once(realpath(dirname(__FILE__))."/mfBaseModel.php"); class mfBaseApicontroller { protected $log; + protected $requestLog; protected $needlogin = false; protected $siteTitle; private $mfAction; @@ -31,24 +32,15 @@ class mfBaseApicontroller { public function __construct($params = NULL) { // load logging facility $this->log = mfLoghandler::singleton(); + $this->requestLog = new mfLog_File(); + $this->requestLog->init(BASEDIR."/var/log/api-request.log"); - $this->log->debug("new API request for ".$_SERVER['REQUEST_URI']); - $logstr = ""; - foreach($_GET as $key => $value) { - $logstr .= "; $key='$value'"; - } - $this->log->debug("GET: ".print_r($_GET, true)); - - $logstr = ""; - foreach($_POST as $key => $value) { - $logstr .= "; $key='$value'"; - } - $this->log->debug("POST: ".print_r($_POST, true)); + $this->logRequest(); $this->loadRequest($params); - - $this->log->debug("POST JSON: ".$this->request_json); - $this->log->debug("HEADERS: ".print_r($this->headers, true)); + if($this->request_json) { + $this->logJsonRequest(); + } register_shutdown_function(["mfBaseApicontroller", "return_errors"]); @@ -86,6 +78,26 @@ class mfBaseApicontroller { } + private function logRequest() { + $this->requestLog->debug("new API request for ".$_SERVER['REQUEST_URI']); + $this->requestLogstr = ""; + foreach($_GET as $key => $value) { + $this->requestLogstr .= "; $key='$value'"; + } + $this->requestLog->debug("GET: ".print_r($_GET, true)); + + $this->requestLogstr = ""; + foreach($_POST as $key => $value) { + $this->requestLogstr .= "; $key='$value'"; + } + $this->requestLog->debug("POST: ".print_r($_POST, true)); + $this->requestLog->debug("Headers: ".print_r($this->headers, true)); + } + + private function logJsonRequest() { + $this->requestLog->debug("POST JSON: ".$this->request_json); + } + private function authenticateUser() { $key = false; //var_dump($this->headers);exit;