Last active
November 24, 2016 09:02
-
-
Save maciejzgadzaj/c18d929489ed8c7e138f5ef901579447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git i/includes/services.runtime.inc w/includes/services.runtime.inc | |
| index b7c7d3c..10a36d6 100644 | |
| --- i/includes/services.runtime.inc | |
| +++ w/includes/services.runtime.inc | |
| @@ -95,8 +95,8 @@ class ServicesArgumentException extends ServicesException { | |
| function services_controller_execute($controller, $args = array(), $options = array()) { | |
| $server_info = services_server_info_object(); | |
| if (!empty($server_info->debug)) { | |
| - watchdog('services', 'Controller: <pre>@controller</pre>', array('@controller' => print_r($controller, TRUE)), WATCHDOG_DEBUG); | |
| - watchdog('services', 'Passed arguments: <pre>@arguments</pre>', array('@arguments' => print_r($args, TRUE)), WATCHDOG_DEBUG); | |
| + watchdog('services', '@resource : Controller: <pre>@controller</pre>', array('@resource' => services_get_current_resource(), '@controller' => print_r($controller, TRUE)), WATCHDOG_DEBUG); | |
| + watchdog('services', '@resource : Passed arguments: <pre>@arguments</pre>', array('@resource' => services_get_current_resource(), '@arguments' => print_r($args, TRUE)), WATCHDOG_DEBUG); | |
| } | |
| // Switch to anonymous user preserving currently session authenticated user. | |
| @@ -117,7 +117,7 @@ function services_controller_execute($controller, $args = array(), $options = ar | |
| } | |
| if (!empty($server_info->debug)) { | |
| - watchdog('services', 'results: <pre>@results</pre>', array('@results' => print_r($result, TRUE)), WATCHDOG_DEBUG); | |
| + watchdog('services', '@resource : results: <pre>@results</pre>', array('@resource' => services_get_current_resource(), '@results' => print_r($result, TRUE)), WATCHDOG_DEBUG); | |
| } | |
| return $result; | |
| } | |
| @@ -200,7 +200,7 @@ function _services_controller_execute_internals($controller, $args, $options) { | |
| // Log the arguments. | |
| if (!empty($server_info->debug)) { | |
| - watchdog('services', 'Called arguments: <pre>@arguments</pre>', array('@arguments' => print_r($args, TRUE)), WATCHDOG_DEBUG); | |
| + watchdog('services', '@resource : Called arguments: <pre>@arguments</pre>', array('@resource' => services_get_current_resource(), '@arguments' => print_r($args, TRUE)), WATCHDOG_DEBUG); | |
| } | |
| // Execute the controller callback. | |
| diff --git i/services.module w/services.module | |
| index c5cda76..e2f1f23 100644 | |
| --- i/services.module | |
| +++ w/services.module | |
| @@ -385,8 +385,8 @@ function services_endpoint_callback($endpoint_name) { | |
| 'settings' => $endpoint->server_settings, | |
| )); | |
| if ($endpoint->debug) { | |
| - watchdog('services', 'Calling server: %server', array('%server' => $server . '_server'), WATCHDOG_DEBUG); | |
| - watchdog('services', 'Server info main object: <pre>@info</pre>', array('@info' => print_r(services_server_info_object(), TRUE)), WATCHDOG_DEBUG); | |
| + watchdog('services', '@resource : Calling server: %server', array('@resource' => services_get_current_resource(), '%server' => $server . '_server'), WATCHDOG_DEBUG); | |
| + watchdog('services', '@resource : Server info main object: <pre>@info</pre>', array('@resource' => services_get_current_resource(), '@info' => print_r(services_server_info_object(), TRUE)), WATCHDOG_DEBUG); | |
| } | |
| print call_user_func($server . '_server'); | |
| @@ -1141,3 +1141,20 @@ function services_features_export_alter(&$export, $module_name) { | |
| ksort($export['dependencies']); | |
| } | |
| } | |
| + | |
| +/** | |
| + * Returns current resource name for debug purposes. | |
| + * | |
| + * @return string | |
| + * Current resource name. | |
| + */ | |
| +function services_get_current_resource() { | |
| + // Get resource canonical path as ServicesContext::getCanonicalPath() does it. | |
| + $endpoint_path = services_get_server_info('endpoint_path', ''); | |
| + $endpoint_path_len = drupal_strlen($endpoint_path . '/'); | |
| + $canonical_path = drupal_substr($_GET['q'], $endpoint_path_len); | |
| + // Get current resource name from the canonical path. | |
| + $canonical_path_elements = explode('/', $canonical_path); | |
| + $resource_name_elements = explode('.', $canonical_path_elements[0]); | |
| + return $_SERVER['REQUEST_METHOD'] . ' ' . $resource_name_elements[0]; | |
| +} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment