public function __construct(RequestInterpolation $requestInterpolation, ResponseInterpolation $responseInterpolation) { $this->requestInterpolation = $requestInterpolation; $this->responseInterpolation = $responseInterpolation; parent::__construct(); }
/** * @param Request $request * @param Response $response */ public function log(Request $request, Response $response) { $this->responseInterpolation->setResponse($response); $this->responseInterpolation->setRequest($request); $this->requestInterpolation->setRequest($request); if (config('request-logger.logger.enabled')) { $format = config('request-logger.logger.format', "{ip} {remote_user} {date} {method} {url} HTTP/{http_version} {status} {content_length} {referer} {user_agent}"); $format = array_get($this->formats, $format, $format); $message = $this->responseInterpolation->interpolate($format); $message = $this->requestInterpolation->interpolate($message); $this->logger->log(config('request-logger.logger.level', 'info'), $message, [static::LOG_CONTEXT]); } }