add rate limits to logs
authorMichael Wallner <mike@php.net>
Wed, 20 May 2015 13:29:04 +0000 (15:29 +0200)
committerMichael Wallner <mike@php.net>
Wed, 20 May 2015 13:29:04 +0000 (15:29 +0200)
app/Github/ClientObserver.php

index 89e01d8f171845586eb09f7164ea77adea682a80..036f303c6e0f6aaf81ddffe1006bed6f262bb196 100644 (file)
@@ -27,7 +27,12 @@ class ClientObserver implements SplObserver
                                break;
                        case "finished":
                                $response = $client->getResponse($request);
-                               $message = sprintf("API-Shot: finished [%d] %s %s", $response->getResponseCode(), $request->getRequestMethod(), $request->getRequestUrl());
+                               $message = sprintf("API-Shot: finished [%d] (rate-limit:%d/%d) %s %s",
+                                       $response->getResponseCode(),
+                                       $response->getHeader("X-RateLimit-Remaining"),
+                                       $response->getHeader("X-RateLimit-Limit"),
+                                       $request->getRequestMethod(),
+                                       $request->getRequestUrl());
                                if ($response->getResponseCode() >= 400 || $response->getTransferInfo("error")) {
                                        $this->logger->error($message, (array) $response->getTransferInfo());
                                } else {