Changeset 422

Show
Ignore:
Timestamp:
03/25/07 00:30:37 (2 years ago)
Author:
mikey
Message:

added possibility to set the log level

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/errorhandler/stubLogErrorHandler.php

    r421 r422  
    6666     */ 
    6767    protected $logTarget     = 'php-error'; 
     68    /** 
     69     * the error level to use for the log data 
     70     * 
     71     * @var  int 
     72     */ 
     73    protected $logLevel      = stubLogger::LEVEL_ERROR; 
    6874     
    6975    /** 
     
    110116     
    111117    /** 
     118     * sets the level of the log data 
     119     * 
     120     * @param  int  $logLevel 
     121     */ 
     122    public function setLogLevel($logLevel) 
     123    { 
     124        $this->logLevel = $logLevel; 
     125    } 
     126     
     127    /** 
    112128     * handle the event 
    113129     *  
     
    212228    protected function log($level, $message, $file = null, $line = null, array $context = array()) 
    213229    { 
    214         $logData = stubLogDataFactory::create($this->session, $this->logTarget, stubLogger::LEVEL_ERROR); 
     230        $logData = stubLogDataFactory::create($this->session, $this->logTarget, $this->logLevel); 
    215231        $logData->addData($level); 
    216232        $logData->addData((isset($this->levelStrings[$level]) == true) ? ($this->levelStrings[$level]) : ('unknown')); 
  • trunk/src/test/php/net/stubbles/util/errorhandler/stubLogErrorHandlerTestCase.php

    r421 r422  
    108108        $this->assertEqual(count($logData), 1); 
    109109        $this->assertEqual($logData[0]->getTarget(), 'php-error'); 
     110        $this->assertEqual($logData[0]->getLevel(), stubLogger::LEVEL_ERROR); 
    110111        $logDataContents = explode(stubLogData::SEPERATOR, $logData[0]->get()); 
    111112        $this->assertEqual($logDataContents[2], E_USER_ERROR); 
     
    135136        ); 
    136137        $this->logErrorHandler->setLogTarget('exampleLogfile'); 
     138        $this->logErrorHandler->setLogLevel(stubLogger::LEVEL_DEBUG); 
    137139         
    138140        $logger      = stubLogger::getInstance(__CLASS__); 
     
    144146        $this->assertEqual(count($logData), 1); 
    145147        $this->assertEqual($logData[0]->getTarget(), 'exampleLogfile'); 
     148        $this->assertEqual($logData[0]->getLevel(), stubLogger::LEVEL_DEBUG); 
    146149        $logDataContents = explode(stubLogData::SEPERATOR, $logData[0]->get()); 
    147150        $this->assertEqual($logDataContents[2], E_RECOVERABLE_ERROR);