Exemple #1
0
 public function __construct($logger = 'default')
 {
     $pathXML = LIB . DS . 'log' . DS . 'config.xml';
     $configurator = new LoggerConfiguratorDefault();
     $config = $configurator->parse($pathXML);
     Logger::configure($config);
     $this->logger = Logger::getLogger($logger);
 }
 public function testConfiguration()
 {
     $config = LoggerConfiguratorDefault::getDefaultConfiguration();
     $config['appenders']['default']['filters'] = array(array('class' => 'LoggerFilterDenyAll'));
     Logger::configure($config);
     $logger = Logger::getRootLogger();
     ob_start();
     $logger->trace('Test');
     $logger->debug('Test');
     $logger->info('Test');
     $logger->warn('Test');
     $logger->error('Test');
     $logger->fatal('Test');
     $actual = ob_get_clean();
     $this->assertEmpty($actual);
 }
 /**
  * @expectedException PHPUnit_Framework_Error
  * @expectedExceptionMessage Invalid configuration provided for appender
  */
 public function testAppenderConfigNotArray()
 {
     $hierachyMock = $this->getMock('LoggerHierarchy', array(), array(), '', false);
     $config = array('appenders' => array('default'));
     $configurator = new LoggerConfiguratorDefault();
     $configurator->configure($hierachyMock, $config);
 }
Exemple #4
0
 private function configureLogger()
 {
     // Configure log files to be separate for each bot
     $configurator = new LoggerConfiguratorDefault();
     $config = $configurator->parse('conf/log4php.xml');
     $file = $config['appenders']['defaultFileAppender']['params']['file'];
     $file = str_replace("./logs/", "./logs/" . $this->getLogFolderName() . "/", $file);
     $config['appenders']['defaultFileAppender']['params']['file'] = $file;
     Logger::configure($config);
 }