From: Brad Jorsch Date: Fri, 8 Aug 2014 09:37:02 +0000 (+0100) Subject: API: Add method for logging feature usage X-Git-Tag: 1.31.0-rc.0~14424 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=a04f1920947e49c3f1bd6d9df4e788503ac905aa;p=lhc%2Fweb%2Fwiklou.git API: Add method for logging feature usage For example, to determine usage levels of deprecated features. Change-Id: Ifd640883e46f3e6c8179c63d122c704b046674ca --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 05f91bcfca..db62be0a0a 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -2227,4 +2227,19 @@ abstract class ApiBase extends ContextSource { } print "\n\n"; } + + /** + * Write logging information for API features to a debug log, for usage + * analysis. + * @param string $feature Feature being used. + */ + protected function logFeatureUsage( $feature ) { + $request = $this->getRequest(); + $s = $feature . + ' ' . wfUrlencode( str_replace( ' ', '_', $this->getUser()->getName() ) ) . + ' ' . $request->getIP() . + ' "' . $request->getHeader( 'Referer' ) . '"' . + ' "' . $request->getHeader( 'User-agent' ) . '"'; + wfDebugLog( 'api-feature-usage', $s, 'private' ); + } }