Skip to content

Commit

Permalink
Change logic for getDefaultLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
Hectorhammett committed Sep 9, 2024
1 parent 7ce3e58 commit ce1e7db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/ApplicationDefaultCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,30 @@ public static function getIdTokenCredentials(
public static function getDefaultLogger(): null|LoggerInterface
{
$loggingFlag = getenv(self::SDK_DEBUG_FLAG);
if ($loggingFlag instanceof string) {
$loggingFlag = strtolower($loggingFlag);

// Env var is not set
if (!is_string($loggingFlag)) {
if (is_array($loggingFlag)) {
trigger_error('The ' . self::SDK_DEBUG_FLAG . ' is set, but it is set to another value than false, true, 0 or 1. Logging is disabled');
return null;
}

return null;
}

if ($loggingFlag === false || $loggingFlag !== 'true' && $loggingFlag !== '1') {
if (strtolower($loggingFlag) !== 'false' && strtolower($loggingFlag) !== '0') {
trigger_error('The ' . self::SDK_DEBUG_FLAG . ' is set, but it is set to another value than false, true or 0. Logging is disabled');
$loggingFlag = strtolower($loggingFlag);

// Env Var is not true
if ($loggingFlag !== 'true' && $loggingFlag !== '1') {
// Env var is set to a non valid value
if ($loggingFlag !== 'false' && $loggingFlag !== '0') {
trigger_error('The ' . self::SDK_DEBUG_FLAG . ' is set, but it is set to another value than false, true, 0 or 1. Logging is disabled');
}

return null;
}


return new StdOutLogger();
}

Expand Down
1 change: 0 additions & 1 deletion tests/HttpHandler/Guzzle7HttpHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Prophecy\Argument;
use Prophecy\Promise\ReturnPromise;
use Psr\Log\LoggerInterface;

/**
Expand Down

0 comments on commit ce1e7db

Please sign in to comment.