Skip to content
Snippets Groups Projects
Commit ba4502f3 authored by Patrick Radtke's avatar Patrick Radtke
Browse files

Php version compat improvements; no longer need to use psr log bridge

parent 5cc26124
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"firebase/php-jwt": "^5.0", "firebase/php-jwt": "^5.0",
"kevinrob/guzzle-cache-middleware": "^3.2", "kevinrob/guzzle-cache-middleware": "^3.2",
"psr/cache": "^1.0", "psr/cache": "^1.0",
"symfony/cache": "^4.3" "symfony/cache": "^4.3|^3.4"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "5.7.*", "phpunit/phpunit": "5.7.*",
......
...@@ -15,7 +15,6 @@ use SimpleSAML\Module; ...@@ -15,7 +15,6 @@ use SimpleSAML\Module;
use SimpleSAML\Module\authoauth2\AttributeManipulator; use SimpleSAML\Module\authoauth2\AttributeManipulator;
use SimpleSAML\Module\authoauth2\ConfigTemplate; use SimpleSAML\Module\authoauth2\ConfigTemplate;
use SimpleSAML\Module\authoauth2\Providers\AdjustableGenericProvider; use SimpleSAML\Module\authoauth2\Providers\AdjustableGenericProvider;
use SimpleSAML\Module\authoauth2\PsrLogBridge;
use SimpleSAML\Utils\HTTP; use SimpleSAML\Utils\HTTP;
/** /**
...@@ -150,7 +149,7 @@ class OAuth2 extends \SimpleSAML\Auth\Source ...@@ -150,7 +149,7 @@ class OAuth2 extends \SimpleSAML\Auth\Source
Logger::debug('authoauth2: Enable traffic logging'); Logger::debug('authoauth2: Enable traffic logging');
$handlerStack = HandlerStack::create(); $handlerStack = HandlerStack::create();
$handlerStack->push( $handlerStack->push(
Middleware::log(new PsrLogBridge(), new MessageFormatter("authoauth2: $providerLabel $format")), Middleware::log(new \SAML2\Compat\Ssp\Logger(), new MessageFormatter("authoauth2: $providerLabel $format")),
'logHttpTraffic' 'logHttpTraffic'
); );
$clientConfig = $config->toArray(); $clientConfig = $config->toArray();
......
<?php
namespace SimpleSAML\Module\authoauth2;
use Psr\Log\LogLevel;
use SAML2\Compat\Ssp\Logger;
/**
* The current version of the PSR compat logging has bugs in their log method
* that prevents logging. See https://github.com/simplesamlphp/saml2/issues/130
*/
class PsrLogBridge extends Logger
{
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
{
switch ($level) {
case LogLevel::ALERT:
$this->alert($message, $context);
break;
case LogLevel::CRITICAL:
$this->critical($message, $context);
break;
case LogLevel::DEBUG:
$this->debug($message, $context);
break;
case LogLevel::EMERGENCY:
$this->emergency($message, $context);
break;
case LogLevel::ERROR:
$this->error($message, $context);
break;
case LogLevel::INFO:
$this->info($message, $context);
break;
case LogLevel::NOTICE:
$this->notice($message, $context);
break;
case LogLevel::WARNING:
$this->warning($message, $context);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment