Follow up questions for this solution: https://stackoverflow.com/a/31883204/3548238
For example something like this:
/**
*
* @status 200
*
* @description Get all logs
* @url GET logs
* @access protected
* @class AccessControl {@requires admin}
*
* @log false
*
* @throws RestException
*/
public function list_all_logs() {
...
...
You should be using onComplete
instead of onRespond
Why?
onRespond()
- fired before sending responseonComplete()
- fired after sending responseHere is the complete solution that answers all your questions, assuming you are adding @log false
comment to the api method you want to exclude
use Luracast\Restler\Restler;
use Luracast\Restler\User;
$r = new Restler();
$r->onComplete(function () use ($r) {
if (
!isset($r->apiMethodInfo->metadata['log']) ||
$r->apiMethodInfo->metadata['log'] == 'true'
) {
$success = $r->responseCode == 200;
$info = array(
'success' => $success,
'message' => $success ? '' : $r->exception->getErrorMessage()
);
print_r($info); //your logging function here!
}
});
$r->addAPIClass('Say');
$r->handle();