merged branch Seldaek/psr3 (PR #6628)

This PR was merged into the master branch.

Commits
-------

67d7423 Remove use of deprecated HttpKernel LoggerInterface
dca4528 [HttpKernel] Extend psr/log's NullLogger class
1e5a890 [Monolog] Mark old non-PSR3 methods as deprecated
91a86f8 [HttpKernel][Monolog] Add PSR-3 support to the LoggerInterface

Discussion
----------

[HttpKernel][MonologBridge] PSR-3 support

This enables PSR-3 support and monolog 1.3+. The first commit is the main part. The rest deals with deprecation of short-hand methods (warn/err/crit/emerg) that are fully expanded in PSR-3 (warning/error/critical/emergency).

The downside of deprecating them is that for bundles it's a bit harder to support older and newer versions. If that is too much of a hassle you can drop that for now and cherry pick the first commit.

The upside is that it forces people to move towards PSR-3 compatible stuff, which means eventually we could completely drop the LoggerInterface from the framework. In any case I think the documentation should only mention the `Psr\Log\LoggerInterface` and people should start hinting against that. The change should be done in core as well I suppose.

Anyway I wanted to throw this out there as it is to get feedback.

---------------------------------------------------------------------------

by stof at 2013-01-09T09:15:15Z

@Seldaek I also think you should change the typehint to use the PSR LoggerInterface in all classes using the logger

---------------------------------------------------------------------------

by Seldaek at 2013-01-09T09:54:55Z

OK updated according to all the feedback. I tested it in an app and it still seems to work so there shouldn't be any major issues.

---------------------------------------------------------------------------

by Seldaek at 2013-01-09T09:59:55Z

@fabpot if you merge please merge also the bundle PR, otherwise it won't be possible to update without conflict.

---------------------------------------------------------------------------

by frosas at 2013-01-10T14:59:20Z

I'm trying to understand why a `composer update` of a Symfony 2.1.* resulted in a fatal error. Shouldn't a stable version don't break like this?

As @olaurendeau points, why Symfony depends 1.* instead of 1.2.*? Or why Monolog 1.3 breaks its public interface (EDIT: I'm not sure about it)? Or why isn't this PR being merged (into branch 2.1) at the same time Monolog 1.3 is released?

Please, understand I'm not looking for who to blame, it's just I want to know if this situation is unexpected or if otherwise a `composer update` on a stable branch is not as innocent as it seems.

---------------------------------------------------------------------------

by stof at 2013-01-10T15:06:51Z

@frosas it cannot be merged into 2.1 as it is a BC break. The 2.1 branch has been updated to forbid Monolog 1.3 already

---------------------------------------------------------------------------

by Seldaek at 2013-01-10T15:11:58Z

@frosas you can blame me for releasing as 1.3.0 and not 2.0, but technically for monolog this isn't really a BC break, I just added an interface. The problem is due to the way it's used in symfony, it ended up as a fatal error. In any case the situation is now sorted out I think.

---------------------------------------------------------------------------

by frosas at 2013-01-10T15:26:43Z

@stof now I see this `>=1.0,<1.3-dev` change in the 2.1 branch. Now, shouldn't a new (2.1.7) version be released for all of us not in the dev minimum-stability?

@Seldaek then do you see feasible to rely only in X.Y.* versions to avoid this kind of errors?

---------------------------------------------------------------------------

by Seldaek at 2013-01-10T15:45:22Z

@frosas relying on X.Y.* is painful because you always need to wait until someone updates the constraint to get the new version. Of course using ~1.3 like in this PR means if I fuck up and break BC people will update to it, but that's a less likely occurrence than the alternative I think, so I would rather not use X.Y.*

---------------------------------------------------------------------------

by frosas at 2013-01-10T15:50:50Z

@Seldaek you are right about this, but I was thinking more in changing it only for the stable versions. EDIT: I mean, how often do you need a new feature in a branch you only apply fixes to?

---------------------------------------------------------------------------

by stof at 2013-01-10T15:57:32Z

@frosas Monolog and Symfony have separate release cycles. Foorcing Symfony users to use an old version of Monolog until they update to a new version of Symfony whereas the newer Monolog is compatible is a bad idea. Thus, as Monolog keeps BC, it does not maintain bugfix releases for all older versions (just like Twig does too). So it would also forbid you to get the fixes done in newer Monolog versions.

The incompatibility between Symfony 2.1 LoggerInterface and PSR-3 (whereas they expect exactly the same behavior and signature for methods with the same name) is unfortunate and is the reason why we get some issues here.

---------------------------------------------------------------------------

by frosas at 2013-01-10T16:21:06Z

@stof I appreciate you prefer to allow newer versions at the price of having to be constantly monitoring its changes to avoid breaks.

Another similar but safer strategy would be to stick to X.Y.* versions and upgrade to X.Y+1.* once the new version integration is tested, but I understand this is discutible in projects as close to Symfony as Monolog.

Returning to the issue, what do you say to release this 2.1.7 version? Or is it only me who is having issues here?

---------------------------------------------------------------------------

by stof at 2013-01-10T16:26:20Z

@frosas a minor release should not break BC when following smeantic versionning (Symfony warned about the fact it is not strictly followed for the first releases of 2.x). But as far as monolog is concerned, 1.3 is BC with 1.2.

---------------------------------------------------------------------------

by Seldaek at 2013-01-10T16:49:55Z

@frosas sorry I didn't get you still had the problem. I tagged a 2.1.7 of monologbundle which hopefully fixes your issue.
This commit is contained in:
Fabien Potencier 2013-01-10 17:57:14 +01:00
commit f0a66db79a
49 changed files with 179 additions and 142 deletions

View File

@ -18,7 +18,8 @@
"require": {
"php": ">=5.3.3",
"doctrine/common": ">2.2,<2.4-dev",
"twig/twig": ">=1.11.0,<2.0-dev"
"twig/twig": ">=1.11.0,<2.0-dev",
"psr/log": "~1.0"
},
"replace": {
"symfony/browser-kit": "self.version",
@ -59,7 +60,7 @@
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": ">=2.2,<2.4-dev",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"monolog/monolog": ">=1.0,<1.3-dev",
"monolog/monolog": "~1.3",
"propel/propel1": "dev-master"
},
"autoload": {

View File

@ -11,7 +11,7 @@
namespace Symfony\Bridge\Doctrine\Logger;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Doctrine\DBAL\Logging\SQLLogger;

View File

@ -47,10 +47,7 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
public function countErrors()
{
$cnt = 0;
$levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT);
if (defined('Monolog\Logger::EMERGENCY')) {
$levels[] = Logger::EMERGENCY;
}
$levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
foreach ($levels as $level) {
if (isset($this->recordsByLevel[$level])) {
$cnt += count($this->recordsByLevel[$level]);

View File

@ -22,6 +22,38 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
*/
class Logger extends BaseLogger implements LoggerInterface, DebugLoggerInterface
{
/**
* @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
*/
public function emerg($message, array $context = array())
{
return parent::addRecord(BaseLogger::EMERGENCY, $message, $context);
}
/**
* @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
*/
public function crit($message, array $context = array())
{
return parent::addRecord(BaseLogger::CRITICAL, $message, $context);
}
/**
* @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
*/
public function err($message, array $context = array())
{
return parent::addRecord(BaseLogger::ERROR, $message, $context);
}
/**
* @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
*/
public function warn($message, array $context = array())
{
return parent::addRecord(BaseLogger::WARNING, $message, $context);
}
/**
* @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface
*/

View File

@ -18,7 +18,7 @@
"require": {
"php": ">=5.3.3",
"symfony/http-kernel": "2.2.*",
"monolog/monolog": ">=1.0,<1.3-dev"
"monolog/monolog": "~1.3"
},
"autoload": {
"psr-0": { "Symfony\\Bridge\\Monolog\\": "" }

View File

@ -12,7 +12,7 @@
namespace Symfony\Bridge\Propel1\Logger;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* PropelLogger.
@ -73,7 +73,7 @@ class PropelLogger
public function crit($message)
{
if (null !== $this->logger) {
$this->logger->crit($message);
$this->logger->critical($message);
}
}
@ -85,7 +85,7 @@ class PropelLogger
public function err($message)
{
if (null !== $this->logger) {
$this->logger->err($message);
$this->logger->error($message);
}
}
@ -97,7 +97,7 @@ class PropelLogger
public function warning($message)
{
if (null !== $this->logger) {
$this->logger->warn($message);
$this->logger->warning($message);
}
}

View File

@ -11,7 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;

View File

@ -14,7 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Routing;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\Config\Loader\DelegatingLoader as BaseDelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* DelegatingLoader delegates route loading to other loaders using a loader resolver.

View File

@ -12,7 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Templating;
use Symfony\Component\Templating\DebuggerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* Binds the Symfony templating loader debugger to the Symfony logger.

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\Controller;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
@ -58,7 +58,7 @@ class ControllerResolver implements ControllerResolverInterface
{
if (!$controller = $request->attributes->get('_controller')) {
if (null !== $this->logger) {
$this->logger->warn('Unable to look for the controller as the "_controller" parameter is missing');
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
}
return false;

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\HttpKernel\Debug;
use Symfony\Component\HttpKernel\Exception\FatalErrorException;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* ErrorHandler.
@ -95,7 +95,7 @@ class ErrorHandler
: debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10)
);
self::$logger->warn($message, $deprecation);
self::$logger->warning($message, $deprecation);
}
return true;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\Debug;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpKernel\HttpKernelInterface;

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Debug\ErrorHandler;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@ -97,9 +97,9 @@ class ExceptionListener implements EventSubscriberInterface
$isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500;
if (null !== $this->logger) {
if ($isCritical) {
$this->logger->crit($message);
$this->logger->critical($message);
} else {
$this->logger->err($message);
$this->logger->error($message);
}
} elseif (!$original || $isCritical) {
error_log($message);

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;

View File

@ -11,52 +11,39 @@
namespace Symfony\Component\HttpKernel\Log;
use Psr\Log\LoggerInterface as PsrLogger;
/**
* LoggerInterface.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since 2.2, to be removed in 3.0. Type-hint \Psr\Log\LoggerInterface instead.
* @api
*/
interface LoggerInterface
interface LoggerInterface extends PsrLogger
{
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
*/
public function emerg($message, array $context = array());
/**
* @api
*/
public function alert($message, array $context = array());
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
*/
public function crit($message, array $context = array());
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
*/
public function err($message, array $context = array());
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
*/
public function warn($message, array $context = array());
/**
* @api
*/
public function notice($message, array $context = array());
/**
* @api
*/
public function info($message, array $context = array());
/**
* @api
*/
public function debug($message, array $context = array());
}

View File

@ -11,7 +11,8 @@
namespace Symfony\Component\HttpKernel\Log;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger as PsrNullLogger;
/**
* NullLogger.
@ -20,10 +21,11 @@ use Symfony\Component\HttpKernel\Log\LoggerInterface;
*
* @api
*/
class NullLogger implements LoggerInterface
class NullLogger extends PsrNullLogger
{
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
*/
public function emerg($message, array $context = array())
{
@ -31,13 +33,7 @@ class NullLogger implements LoggerInterface
/**
* @api
*/
public function alert($message, array $context = array())
{
}
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
*/
public function crit($message, array $context = array())
{
@ -45,6 +41,7 @@ class NullLogger implements LoggerInterface
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
*/
public function err($message, array $context = array())
{
@ -52,29 +49,9 @@ class NullLogger implements LoggerInterface
/**
* @api
* @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
*/
public function warn($message, array $context = array())
{
}
/**
* @api
*/
public function notice($message, array $context = array())
{
}
/**
* @api
*/
public function info($message, array $context = array())
{
}
/**
* @api
*/
public function debug($message, array $context = array())
{
}
}

View File

@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface;
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* Profiler.
@ -110,7 +110,7 @@ class Profiler
public function saveProfile(Profile $profile)
{
if (!($ret = $this->storage->write($profile)) && null !== $this->logger) {
$this->logger->warn('Unable to store the profiler information.');
$this->logger->warning('Unable to store the profiler information.');
}
return $ret;

View File

@ -30,7 +30,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
$request = Request::create('/');
$this->assertFalse($resolver->getController($request), '->getController() returns false when the request has no _controller attribute');
$this->assertEquals(array('Unable to look for the controller as the "_controller" parameter is missing'), $logger->getLogs('warn'));
$this->assertEquals(array('Unable to look for the controller as the "_controller" parameter is missing'), $logger->getLogs('warning'));
$request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\ControllerResolverTest::testGetController');
$controller = $resolver->getController($request);

View File

@ -67,7 +67,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler();
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
$logger = $this->getMock('Psr\Log\LoggerInterface');
$that = $this;
$warnArgCheck = function($message, $context) use ($that) {
@ -84,7 +84,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$logger
->expects($this->once())
->method('warn')
->method('warning')
->will($this->returnCallback($warnArgCheck))
;

View File

@ -102,7 +102,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testLogger()
{
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
$logger = $this->getMock('Psr\Log\LoggerInterface');
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
@ -117,7 +117,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testLoggerWithStoppedEvent()
{
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
$logger = $this->getMock('Psr\Log\LoggerInterface');
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);

View File

@ -93,7 +93,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
}
$this->assertEquals(3, $logger->countErrors());
$this->assertCount(3, $logger->getLogs('crit'));
$this->assertCount(3, $logger->getLogs('critical'));
}
public function provider()
@ -117,7 +117,7 @@ class TestLogger extends Logger implements DebugLoggerInterface
{
public function countErrors()
{
return count($this->logs['crit']);
return count($this->logs['critical']);
}
}

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\Tests;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
class Logger implements LoggerInterface
{
@ -22,67 +22,107 @@ class Logger implements LoggerInterface
$this->clear();
}
public function getLogs($priority = false)
public function getLogs($level = false)
{
return false === $priority ? $this->logs : $this->logs[$priority];
return false === $level ? $this->logs : $this->logs[$level];
}
public function clear()
{
$this->logs = array(
'emerg' => array(),
'emergency' => array(),
'alert' => array(),
'crit' => array(),
'err' => array(),
'warn' => array(),
'critical' => array(),
'error' => array(),
'warning' => array(),
'notice' => array(),
'info' => array(),
'debug' => array(),
);
}
public function log($message, $priority)
public function log($level, $message, array $context = array())
{
$this->logs[$priority][] = $message;
$this->logs[$level][] = $message;
}
public function emerg($message, array $context = array())
public function emergency($message, array $context = array())
{
$this->log($message, 'emerg');
$this->log('emergency', $message, $context);
}
public function alert($message, array $context = array())
{
$this->log($message, 'alert');
$this->log('alert', $message, $context);
}
public function crit($message, array $context = array())
public function critical($message, array $context = array())
{
$this->log($message, 'crit');
$this->log('critical', $message, $context);
}
public function err($message, array $context = array())
public function error($message, array $context = array())
{
$this->log($message, 'err');
$this->log('error', $message, $context);
}
public function warn($message, array $context = array())
public function warning($message, array $context = array())
{
$this->log($message, 'warn');
$this->log('warning', $message, $context);
}
public function notice($message, array $context = array())
{
$this->log($message, 'notice');
$this->log('notice', $message, $context);
}
public function info($message, array $context = array())
{
$this->log($message, 'info');
$this->log('info', $message, $context);
}
public function debug($message, array $context = array())
{
$this->log($message, 'debug');
$this->log('debug', $message, $context);
}
/**
* @deprecated
*/
public function emerg($message, array $context = array())
{
trigger_error('Use emergency() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('emergency', $message, $context);
}
/**
* @deprecated
*/
public function crit($message, array $context = array())
{
trigger_error('Use crit() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('critical', $message, $context);
}
/**
* @deprecated
*/
public function err($message, array $context = array())
{
trigger_error('Use err() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('error', $message, $context);
}
/**
* @deprecated
*/
public function warn($message, array $context = array())
{
trigger_error('Use warn() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('warning', $message, $context);
}
}

View File

@ -18,7 +18,8 @@
"require": {
"php": ">=5.3.3",
"symfony/event-dispatcher": "2.2.*",
"symfony/http-foundation": "2.2.*"
"symfony/http-foundation": "2.2.*",
"psr/log": "~1.0"
},
"require-dev": {
"symfony/browser-kit": "2.2.*",

View File

@ -47,7 +47,7 @@ class PhpGeneratorDumper extends GeneratorDumper
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* {$options['class']}

View File

@ -16,7 +16,7 @@ use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* UrlGenerator can generate a URL or a path for any route in the RouteCollection
@ -168,7 +168,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
if ($this->logger) {
$this->logger->err($message);
$this->logger->error($message);
}
return null;
@ -221,7 +221,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
if ($this->logger) {
$this->logger->err($message);
$this->logger->error($message);
}
return null;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Routing;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;

View File

@ -207,14 +207,14 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
{
if (!interface_exists('Symfony\Component\HttpKernel\Log\LoggerInterface')) {
$this->markTestSkipped('The "HttpKernel" component is not available');
if (!interface_exists('Psr\Log\LoggerInterface')) {
$this->markTestSkipped('The "psr/log" package is not available');
}
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger->expects($this->once())
->method('err');
->method('error');
$generator = $this->getGenerator($routes, array(), $logger);
$generator->setStrictRequirements(false);
$this->assertNull($generator->generate('test', array('foo' => 'bar'), true));

View File

@ -22,7 +22,8 @@
"symfony/config": "2.2.*",
"symfony/yaml": "2.2.*",
"symfony/http-kernel": "2.2.*",
"doctrine/common": ">=2.2,<2.4-dev"
"doctrine/common": ">=2.2,<2.4-dev",
"psr/log": "~1.0"
},
"suggest": {
"symfony/config": "2.2.*",

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Security\Acl\Voter;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Acl\Exception\NoAceFoundException;
use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
use Symfony\Component\Security\Acl\Model\AclProviderInterface;

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Security\Core\Util;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* A secure random number generator implementation.

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http\Authentication;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Http\HttpUtils;

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface
use Symfony\Component\Security\Core\Exception\NonceExpiredException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* DigestAuthenticationEntryPoint starts an HTTP Digest authentication.

View File

@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\SessionUnavailableException;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

View File

@ -18,7 +18,7 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

View File

@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Http\AccessMapInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Http\AccessMapInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@ -89,7 +89,7 @@ class ContextListener implements ListenerInterface
$token = $this->refreshUser($token);
} elseif (null !== $token) {
if (null !== $this->logger) {
$this->logger->warn(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token)));
$this->logger->warning(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token)));
}
$token = null;
@ -161,7 +161,7 @@ class ContextListener implements ListenerInterface
// let's try the next user provider
} catch (UsernameNotFoundException $notFound) {
if (null !== $this->logger) {
$this->logger->warn(sprintf('Username "%s" could not be found.', $user->getUsername()));
$this->logger->warning(sprintf('Username "%s" could not be found.', $user->getUsername()));
}
return null;

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;

View File

@ -23,7 +23,7 @@ use Symfony\Component\Security\Core\Exception\InsufficientAuthenticationExceptio
use Symfony\Component\Security\Core\Exception\LogoutException;
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
@ -136,7 +136,7 @@ class ExceptionListener
}
} catch (\Exception $e) {
if (null !== $this->logger) {
$this->logger->err(sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()));
$this->logger->error(sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()));
}
$event->setException(new \RuntimeException('Exception thrown when handling an exception.', 0, $e));

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
@ -82,7 +82,7 @@ class RememberMeListener implements ListenerInterface
}
} catch (AuthenticationException $failed) {
if (null !== $this->logger) {
$this->logger->warn(
$this->logger->warning(
'SecurityContext not populated with remember-me token as the'
.' AuthenticationManager rejected the AuthenticationToken returned'
.' by the RememberMeServices: '.$failed->getMessage()

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\RedirectResponse;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

View File

@ -22,7 +22,7 @@ use Symfony\Component\Security\Core\Exception\CookieTheftException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Psr\Log\LoggerInterface;
/**
* Base class implementing the RememberMeServicesInterface
@ -129,7 +129,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
}
} catch (UnsupportedUserException $unSupported) {
if (null !== $this->logger) {
$this->logger->warn('User class for remember-me cookie not supported.');
$this->logger->warning('User class for remember-me cookie not supported.');
}
} catch (AuthenticationException $invalid) {
if (null !== $this->logger) {

View File

@ -177,7 +177,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
protected function getLogger()
{
return $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
return $this->getMock('Psr\Log\LoggerInterface');
}
protected function getManager()

View File

@ -26,7 +26,8 @@
"symfony/routing": "2.2.*",
"symfony/validator": "2.2.*",
"doctrine/common": ">=2.2,<2.4-dev",
"doctrine/dbal": ">=2.2,<2.4-dev"
"doctrine/dbal": ">=2.2,<2.4-dev",
"psr/log": "~1.0"
},
"suggest": {
"symfony/class-loader": "2.2.*",