propel-bundle/Logger/PropelLogger.php
2011-09-14 09:58:28 +02:00

138 lines
2.9 KiB
PHP

<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\PropelBundle\Logger;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
/**
* PropelLogger.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @author William DURAND <william.durand1@gmail.com>
*/
class PropelLogger
{
/**
* @var LoggerInterface
*/
protected $logger;
/**
* @var array
*/
protected $queries;
/**
* Constructor.
*
* @param LoggerInterface $logger A LoggerInterface instance
*/
public function __construct(LoggerInterface $logger = null)
{
$this->logger = $logger;
$this->queries = array();
}
/**
* A convenience function for logging an alert event.
*
* @param mixed $message the message to log.
*/
public function alert($message)
{
if (null !== $this->logger) {
$this->logger->alert($message);
}
}
/**
* A convenience function for logging a critical event.
*
* @param mixed $message the message to log.
*/
public function crit($message)
{
if (null !== $this->logger) {
$this->logger->crit($message);
}
}
/**
* A convenience function for logging an error event.
*
* @param mixed $message the message to log.
*/
public function err($message)
{
if (null !== $this->logger) {
$this->logger->err($message);
}
}
/**
* A convenience function for logging a warning event.
*
* @param mixed $message the message to log.
*/
public function warning($message)
{
if (null !== $this->logger) {
$this->logger->warn($message);
}
}
/**
* A convenience function for logging an critical event.
*
* @param mixed $message the message to log.
*/
public function notice($message)
{
if (null !== $this->logger) {
$this->logger->notice($message);
}
}
/**
* A convenience function for logging an critical event.
*
* @param mixed $message the message to log.
*/
public function info($message)
{
if (null !== $this->logger) {
$this->logger->info($message);
}
}
/**
* A convenience function for logging a debug event.
*
* @param mixed $message the message to log.
*/
public function debug($message)
{
$this->queries[] = $message;
if (null !== $this->logger) {
$this->logger->debug($message);
}
}
/**
* Returns queries.
*
* @return array Queries
*/
public function getQueries()
{
return $this->queries;
}
}