From f35e295f6869a2a2034844dfd6f31d5973dbbb04 Mon Sep 17 00:00:00 2001 From: Hector Mendoza Jacobo Date: Tue, 3 Dec 2024 20:19:07 +0000 Subject: [PATCH] Add the internal tag to internal classes --- src/Logging/LoggingTrait.php | 13 +++++++++---- src/Logging/RpcLogEvent.php | 5 +++++ src/Logging/StdOutLogger.php | 4 +++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Logging/LoggingTrait.php b/src/Logging/LoggingTrait.php index 236431a3f..9c2d48567 100644 --- a/src/Logging/LoggingTrait.php +++ b/src/Logging/LoggingTrait.php @@ -19,6 +19,11 @@ use Psr\Log\LogLevel; +/** + * A trait used to call a PSR-3 logging interface. + * + * @internal + */ trait LoggingTrait { /** @@ -47,7 +52,7 @@ private function logRequest(RpcLogEvent $event): void // Remove null values $debugEvent['jsonPayload'] = array_filter($jsonPayload, fn ($value) => !is_null($value)); - $stringifiedEvent = json_encode($debugEvent); + $stringifiedEvent = json_encode($debugEvent, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // There was an error stringifying the event, return to not break execution if ($stringifiedEvent === false) { @@ -70,7 +75,7 @@ private function logResponse(RpcLogEvent $event): void 'jsonPayload' => [ 'response.headers' => $event->headers, 'response.payload' => $this->truncatePayload($event->payload), - 'latency' => $event->latency, + 'latencyMillis' => $event->latency, ] ]; @@ -81,7 +86,7 @@ private function logResponse(RpcLogEvent $event): void fn ($value) => !is_null($value) ); - $stringifiedEvent = json_encode($debugEvent); + $stringifiedEvent = json_encode($debugEvent, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // There was an error stringifying the event, return to not break execution if ($stringifiedEvent !== false) { @@ -114,7 +119,7 @@ private function logStatus(RpcLogEvent $event): void fn ($value) => !is_null($value) ); - $stringifiedEvent = json_encode($infoEvent); + $stringifiedEvent = json_encode($infoEvent, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // There was an error stringifying the event, return to not break execution if ($stringifiedEvent === false) { diff --git a/src/Logging/RpcLogEvent.php b/src/Logging/RpcLogEvent.php index 029cae313..3095eabcf 100644 --- a/src/Logging/RpcLogEvent.php +++ b/src/Logging/RpcLogEvent.php @@ -17,6 +17,11 @@ namespace Google\Auth\Logging; +/** + * A class that contains all the required information for logging. + * + * @internal + */ class RpcLogEvent { /** diff --git a/src/Logging/StdOutLogger.php b/src/Logging/StdOutLogger.php index db4185a18..27b1f0eb3 100644 --- a/src/Logging/StdOutLogger.php +++ b/src/Logging/StdOutLogger.php @@ -24,7 +24,9 @@ use Stringable; /** - * A basic logger class to log into stdOut for GCP logging + * A basic logger class to log into stdOut for GCP logging. + * + * @internal */ class StdOutLogger implements LoggerInterface {