[PropelBundle] added logging
This commit is contained in:
parent
c1e0c3edba
commit
a7e20687f6
@ -57,7 +57,8 @@ class PropelExtension extends LoaderExtension
|
|||||||
'user' => 'root',
|
'user' => 'root',
|
||||||
'password' => null,
|
'password' => null,
|
||||||
'dsn' => null,
|
'dsn' => null,
|
||||||
'classname' => 'PropelPDO',
|
// FIXME: should be automatically changed based on %kernel.debug%
|
||||||
|
'classname' => 'DebugPDO', //'PropelPDO',
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
'attributes' => array(),
|
'attributes' => array(),
|
||||||
// FIXME: Mysql wants UTF8, not UTF-8 (%kernel.charset%)
|
// FIXME: Mysql wants UTF8, not UTF-8 (%kernel.charset%)
|
||||||
@ -75,7 +76,11 @@ class PropelExtension extends LoaderExtension
|
|||||||
$connections = array($config['default_connection'] => $config);
|
$connections = array($config['default_connection'] => $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
$c = array('datasources' => array());
|
$c = array(
|
||||||
|
// FIXME: should be the same value as %zend.logger.priority%
|
||||||
|
'log' => array('level' => 7),
|
||||||
|
'datasources' => array(),
|
||||||
|
);
|
||||||
foreach ($connections as $name => $connection) {
|
foreach ($connections as $name => $connection) {
|
||||||
$connection = array_replace($defaultConnection, $connection);
|
$connection = array_replace($defaultConnection, $connection);
|
||||||
|
|
||||||
@ -92,9 +97,6 @@ class PropelExtension extends LoaderExtension
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//// FIXME
|
|
||||||
|
|
||||||
// $c['classmap'] = //...;
|
|
||||||
|
|
||||||
$configuration->getDefinition('propel.configuration')->setArguments(array($c));
|
$configuration->getDefinition('propel.configuration')->setArguments(array($c));
|
||||||
|
|
||||||
|
119
src/Symfony/Framework/PropelBundle/Logger/PropelLogger.php
Normal file
119
src/Symfony/Framework/PropelBundle/Logger/PropelLogger.php
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symfony\Framework\PropelBundle\Logger;
|
||||||
|
|
||||||
|
use Symfony\Foundation\LoggerInterface;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony framework.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PropelLogger.
|
||||||
|
*
|
||||||
|
* @package Symfony
|
||||||
|
* @subpackage Framework_DoctrineBundle
|
||||||
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||||
|
*/
|
||||||
|
class PropelLogger implements \BasicLogger
|
||||||
|
{
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param LoggerInterface $logger A LoggerInterface instance
|
||||||
|
*/
|
||||||
|
public function __construct(LoggerInterface $logger = null)
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log message.
|
||||||
|
*
|
||||||
|
* @param string $message The message to log
|
||||||
|
* @param int $severity The numeric severity
|
||||||
|
*/
|
||||||
|
public function log($message, $severity = 6)
|
||||||
|
{
|
||||||
|
if (null !== $this->logger) {
|
||||||
|
$this->logger->log($message, $severity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging an alert event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function alert($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging a critical event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function crit($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging an error event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function err($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging a warning event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function warning($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging an critical event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function notice($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging an critical event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function info($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function for logging a debug event.
|
||||||
|
*
|
||||||
|
* @param mixed $message the message to log.
|
||||||
|
*/
|
||||||
|
public function debug($message)
|
||||||
|
{
|
||||||
|
$this->log($message, 7);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="propel.class">Propel</parameter>
|
<parameter key="propel.class">Propel</parameter>
|
||||||
<parameter key="propel.configuration.class">PropelConfiguration</parameter>
|
<parameter key="propel.configuration.class">PropelConfiguration</parameter>
|
||||||
|
<parameter key="propel.logger.class">Symfony\Framework\PropelBundle\Logger\PropelLogger</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
@ -14,14 +15,17 @@
|
|||||||
<call method="setConfiguration">
|
<call method="setConfiguration">
|
||||||
<argument type="service" id="propel.configuration" />
|
<argument type="service" id="propel.configuration" />
|
||||||
</call>
|
</call>
|
||||||
|
<call method="setLogger">
|
||||||
|
<argument type="service" id="propel.logger" />
|
||||||
|
</call>
|
||||||
<call method="initialize" />
|
<call method="initialize" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="propel.configuration" class="%propel.configuration.class%" />
|
<service id="propel.configuration" class="%propel.configuration.class%" />
|
||||||
<!--
|
|
||||||
<service id="propel.logger" class="%propel.logger.class%">
|
<service id="propel.logger" class="%propel.logger.class%">
|
||||||
<argument></argument>
|
<argument type="service" id="logger" on-invalid="null" />
|
||||||
</service>
|
</service>
|
||||||
//-->
|
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
Reference in New Issue
Block a user