[Monolog] Mark old non-PSR3 methods as deprecated

This commit is contained in:
Jordi Boggiano 2013-01-08 23:27:26 +01:00
parent 91a86f8bec
commit 1e5a890864
13 changed files with 54 additions and 17 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",
@ -60,7 +61,6 @@
"doctrine/dbal": ">=2.2,<2.4-dev",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"monolog/monolog": "~1.3",
"psr/log": "~1.0",
"propel/propel1": "dev-master"
},
"autoload": {

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

@ -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

@ -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

@ -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

@ -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

@ -18,27 +18,32 @@ use Psr\Log\LoggerInterface as PsrLogger;
*
* @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 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
* @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());
}

View File

@ -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

@ -166,7 +166,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
if ($this->logger) {
$this->logger->err($message);
$this->logger->error($message);
}
return null;
@ -224,7 +224,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
if ($this->logger) {
$this->logger->err($message);
$this->logger->error($message);
}
return null;

View File

@ -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

@ -134,7 +134,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

@ -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

@ -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) {