i have a controller which will execute based on my customer request, inside that controller function im using an external api (in php curl ) which will return me a unique request number , when my external api fails to return that unique number i will execute the whole controller function again and again until i get the unique number using loop.
so my question is : is there any way to store the execution log of my controller to a file or to db , my log need the data such as : date, time,number of execution , user request .
{
$method = $_SERVER['REQUEST_METHOD'];
if ($method != 'POST') {
json_output(400, array('status' => '400', 'message' => 'Bad request.'));
} else {
$data = $this->security->xss_clean($this->input->raw_input_stream);
$request = json_decode($data);
$PassengerReqAirportID = $request->AirportID;
$PassengerReqNationality = $request->Nationality;
do{
/* To Push Data to external api */
$curl = curl_init();
curl_setopt_array($curl1, array(
CURLOPT_URL => 'http://123.com/api',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"AirportID": "'.$PassengerReqAirportID.'",
"Nation":"'.$PassengerReqNationality.'"}',
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response,true);
$visitID = $response['AccessionNumber'];
} while (!array_key_exists('AccessionNumber',$response) || ($visitID == NULL));
// data i need $visitID```
above is my example code
avoid bad english