/**
  * Return the propel connection name.
  *
  * Usage:
  * $data = SomeClass:doSelect($criteria, avrPropelTools::getConnection())
  *
  * @return string
  */
 public static function getConnection()
 {
     $connection = 'guest';
     if (sfContext::getInstance()->getUser()->isAuthenticated()) {
         $connection = 'propel';
     }
     myLogger::logEvent(__METHOD__ . ': connection=' . $connection, myLogger::LOGEVENT_DEBUG);
     return Propel::getConnection($connection);
 }
예제 #2
0
파일: sfLoggerTest.php 프로젝트: hunde/bsc
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(136);
class myLogger extends sfLogger
{
    public $log = '';
    protected function doLog($message, $priority)
    {
        $this->log .= $message;
    }
}
class notaLogger
{
}
$dispatcher = new sfEventDispatcher();
$logger = new myLogger($dispatcher, array('log_dir_name' => '/tmp'));
$options = $logger->getOptions();
$t->is($options['log_dir_name'], '/tmp', '->getOptions() returns the options for the logger instance');
// ->setLogLevel() ->getLogLevel()
$t->diag('->setLogLevel() ->getLogLevel()');
$t->is($logger->getLogLevel(), sfLogger::INFO, '->getLogLevel() gets the current log level');
$logger->setLogLevel(sfLogger::WARNING);
$t->is($logger->getLogLevel(), sfLogger::WARNING, '->setLogLevel() sets the log level');
$logger->setLogLevel('err');
$t->is($logger->getLogLevel(), sfLogger::ERR, '->setLogLevel() accepts a class constant or a string as its argument');
// ->initialize()
$t->diag('->initialize()');
$logger->initialize($dispatcher, array('level' => sfLogger::ERR));
$t->is($logger->getLogLevel(), sfLogger::ERR, '->initialize() takes an array of options as its second argument');
// ::getPriorityName()
$t->diag('::getPriorityName()');