Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Last active March 18, 2022 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamsilverstein/2ff62d8ee69ed09a6f734176e36192d4 to your computer and use it in GitHub Desktop.
Save adamsilverstein/2ff62d8ee69ed09a6f734176e36192d4 to your computer and use it in GitHub Desktop.
diff --git a/includes/Core/Authentication/Clients/OAuth_Client.php b/includes/Core/Authentication/Clients/OAuth_Client.php
index 3039cc9d0..a08b2e4a4 100644
--- a/includes/Core/Authentication/Clients/OAuth_Client.php
+++ b/includes/Core/Authentication/Clients/OAuth_Client.php
@@ -229,18 +229,50 @@ final class OAuth_Client {
// Enable exponential retries, try up to three times.
$client->setConfig( 'retry', array( 'retries' => 3 ) );
+ $client->setLogger(new class implements \Google\Site_Kit_Dependencies\Psr\Log\LoggerInterface {
+ public function emergency($message, array $context = array()) {
+ error_log( sprintf( 'emergency msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function alert($message, array $context = array()) {
+ error_log( sprintf( 'alert msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function critical($message, array $context = array()) {
+ error_log( sprintf( 'critical msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function error($message, array $context = array()) {
+ error_log( sprintf( 'error msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function warning($message, array $context = array()) {
+ error_log( sprintf( 'warning msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function notice($message, array $context = array()) {
+ error_log( sprintf( 'notice msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function info($message, array $context = array()) {
+ error_log( sprintf( 'info msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function debug($message, array $context = array()) {
+ error_log( sprintf( 'debug msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ public function log($level, $message, array $context = array()) {
+ error_log( sprintf( 'log msg: %s, context: %s ' , $message, json_encode( $context, JSON_PRETTY_PRINT ) ) );
+ }
+ });
+
// Override the default user-agent for the Guzzle client. This is used for oauth/token requests.
// By default this header uses the generic Guzzle client's user-agent and includes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment