Skip to content

Commit c2d4896

Browse files
committed
Add in response code logging
`response_code` smallint(3) NOT NULL, should be appended to log table schema
1 parent 9792680 commit c2d4896

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

application/libraries/REST_Controller.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ public function response($data = NULL, $http_code = NULL, $continue = FALSE)
494494
}
495495

496496
set_status_header($http_code);
497-
497+
$this->_log_response_code($http_code);
498+
498499
// If zlib.output_compression is enabled it will compress the output,
499500
// but it will not modify the content-length header to compensate for
500501
// the reduction, causing the browser to hang waiting for more data.
@@ -1512,7 +1513,20 @@ protected function _log_access_time()
15121513

15131514
return $this->rest->db->update(config_item('rest_logs_table'), $payload, array('id' => $this->_insert_id));
15141515
}
1515-
1516+
1517+
/**
1518+
* updates the log with response code result
1519+
*
1520+
* @author Justin Chen
1521+
* @return boolean
1522+
*/
1523+
1524+
protected function _log_response_code($http_code)
1525+
{
1526+
$payload['response_code'] = $http_code;
1527+
return $this->rest->db->update(config_item('rest_logs_table'), $payload, array('id' => $this->_insert_id));
1528+
}
1529+
15161530
/**
15171531
* Check to see if the API key has access to the controller and methods
15181532
*

0 commit comments

Comments
 (0)