Merge "Provide VRS objects with a name for more informative debugging/logging"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 14 Sep 2015 19:54:06 +0000 (19:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 14 Sep 2015 19:54:06 +0000 (19:54 +0000)
includes/libs/virtualrest/ParsoidVirtualRESTService.php
includes/libs/virtualrest/RestbaseVirtualRESTService.php
includes/libs/virtualrest/SwiftVirtualRESTService.php
includes/libs/virtualrest/VirtualRESTService.php

index 2a179be..43dfab3 100644 (file)
@@ -54,6 +54,7 @@ class ParsoidVirtualRESTService extends VirtualRESTService {
                }
                // set up defaults and merge them with the given params
                $mparams = array_merge( array(
+                       'name' => 'parsoid',
                        'url' => 'http://localhost:8000/',
                        'prefix' => 'localhost',
                        'domain' => 'localhost',
index bc520aa..3a7bc58 100644 (file)
@@ -48,6 +48,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
        public function __construct( array $params ) {
                // set up defaults and merge them with the given params
                $mparams = array_merge( array(
+                       'name' => 'restbase',
                        'url' => 'http://localhost:7231/',
                        'domain' => 'localhost',
                        'timeout' => 100,
index 011dabe..88b0e1f 100644 (file)
@@ -45,7 +45,11 @@ class SwiftVirtualRESTService extends VirtualRESTService {
         *   - swiftAuthTTL       : Swift authentication TTL (seconds)
         */
        public function __construct( array $params ) {
-               parent::__construct( $params );
+               // set up defaults and merge them with the given params
+               $mparams = array_merge( array(
+                       'name' => 'swift'
+               ), $params );
+               parent::__construct( $mparams );
        }
 
        /**
index 2a0b3f0..01a4ea6 100644 (file)
@@ -44,6 +44,17 @@ abstract class VirtualRESTService {
                $this->params = $params;
        }
 
+       /**
+        * Return the name of this service, in a form suitable for error
+        * reporting or debugging.
+        *
+        * @return string The name of the service behind this VRS object.
+        */
+       public function getName() {
+               return isset( $this->params['name'] ) ? $this->params['name'] :
+                       get_class( $this );
+       }
+
        /**
         * Prepare virtual HTTP(S) requests (for this service) for execution
         *