Add request information in API logging #374
This commit is contained in:
parent
1e23f0cd55
commit
63bb887370
1 changed files with 14 additions and 9 deletions
|
|
@ -13,24 +13,29 @@ class LogSubscriber implements EventSubscriberInterface
|
|||
{
|
||||
protected $allow;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->allow = true;
|
||||
}
|
||||
|
||||
public function onKernelController(ControllerEvent $event)
|
||||
{
|
||||
$controller = $event->getController();
|
||||
$this->allow = false;
|
||||
|
||||
// when a controller class defines multiple action methods, the controller
|
||||
// is returned as [$controllerInstance, 'methodName']
|
||||
if (is_array($controller))
|
||||
$controller = $controller[0];
|
||||
|
||||
if ($controller instanceof LoggedController)
|
||||
$this->allow = true;
|
||||
else
|
||||
$this->allow = false;
|
||||
if (!($controller instanceof LoggedController))
|
||||
return;
|
||||
|
||||
$this->allow = true;
|
||||
|
||||
$req = $event->getRequest();
|
||||
$reqdata = [
|
||||
$req->getPathInfo(),
|
||||
$req->getMethod(),
|
||||
$req->query->all(),
|
||||
$req->request->all(),
|
||||
];
|
||||
error_log(print_r($req_data, true));
|
||||
}
|
||||
|
||||
public function onKernelResponse(ResponseEvent $event)
|
||||
|
|
|
|||
Loading…
Reference in a new issue