From 9ce8ae05c727694e54c961f3e2dd6a2b60892848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 2 Oct 2019 00:17:36 +0200 Subject: [PATCH] ApiVisualEditor: Add logging for RESTBase HTTP errors Bug: T233127 Change-Id: Ide5138d8f8f462b9c3d7da10f26ff57c9d17f1c9 --- includes/ApiVisualEditor.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/ApiVisualEditor.php b/includes/ApiVisualEditor.php index afc8c1bb7e..696bdeb2d3 100644 --- a/includes/ApiVisualEditor.php +++ b/includes/ApiVisualEditor.php @@ -10,6 +10,7 @@ use MediaWiki\Block\DatabaseBlock; use MediaWiki\MediaWikiServices; +use MediaWiki\Logger\LoggerFactory; class ApiVisualEditor extends ApiBase { @@ -25,6 +26,11 @@ class ApiVisualEditor extends ApiBase { */ protected $serviceClient; + /** + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + /** * @inheritDoc */ @@ -32,6 +38,7 @@ public function __construct( ApiMain $main, $name, Config $config ) { parent::__construct( $main, $name ); $this->veConfig = $config; $this->serviceClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) ); + $this->logger = LoggerFactory::getInstance( 'VisualEditor' ); } /** @@ -127,6 +134,17 @@ protected function requestRestbase( Title $title, $method, $path, $params, $reqh ); } else { // error null, code not 200 + $this->logger->warning( + __METHOD__ . ": Received HTTP {code} from RESTBase", + [ + 'code' => $response['code'], + 'trace' => ( new Exception )->getTraceAsString(), + 'response' => $response['body'], + 'requestPath' => $path, + /** @phan-suppress-next-line PhanTypeInvalidDimOffset */ + 'requestIfMatch' => $reqheaders['If-Match'] ?? '', + ] + ); $this->dieWithError( [ 'apierror-visualeditor-docserver-http', $response['code'] ], 'apierror-visualeditor-docserver-http'