<?php
/**
 * @package tests
 * @author VxR <vxr@vxr.it>
 * @version $Revision: 1.4 $
 * @since 0.3
 */


/**
 * Test class
 * 
 * @package tests
 * @author VxR <vxr@vxr.it>
 * @version $Revision: 1.4 $
 * @since 0.3
 */
class Test {

    var $logger;

    function Test()
    {
        $this->logger =& LoggerManager::getLogger('Test');
    }
    
    function testLog()
    {
        $this->logger->debug('this is a DEBUG log generated by Test::testLog() class');
        $this->logger->info('this is an INFO log generated by Test::testLog() class');
        $this->logger->warn('this is a WARN log generated by Test::testLog() class');
        $this->logger->error('this is an ERROR log generated by Test::testLog() class');
        $this->logger->fatal('this is a FATAL log generated by Test::testLog() class');                                
    }

}

/**
 * Derived Test class
 * 
 * @package tests
 * @author VxR <vxr@vxr.it>
 * @version $Revision: 1.4 $
 * @since 0.3
 */
class TestTest extends Test {

    var $logger;
    
    function TestTest()
    {
        $this->Test();    
        $this->logger =& LoggerManager::getLogger('Test.Test');
    }
    
    function testLog()
    {
        LoggerNDC::push('NDC generated by TestTest::testLog()');
    
        $this->logger->debug('this is a DEBUG log generated by TestTest::testLog() class');
        $this->logger->info('this is an INFO log generated by TestTest::testLog() class');
        $this->logger->warn('this is a WARN log generated by TestTest::testLog() class');
        $this->logger->error('this is an ERROR log generated by TestTest::testLog() class');
        $this->logger->fatal('this is a FATAL log generated by TestTest::testLog() class');
        
        LoggerNDC::pop();                                
    }

} 

/**
 * Test Function
 * 
 * @author VxR <vxr@vxr.it>
 * @version $Revision: 1.4 $
 * @since 0.3
 */
function Bar()
{
    $logger =& LoggerManager::getLogger('bar');
    // tries to log an array
    $logger->debug(array('one', 'two', 'tree'));
    $logger->info('this is an INFO log generated by Bar() function');
    $logger->warn('this is a WARN log generated by Bar() function');
    $logger->error('this is an ERROR log generated by Bar() function');
    $logger->fatal('this is a FATAL log generated by Bar() function');
    
}

$logger =& LoggerManager::getLogger('main');

$logger->debug('this is a DEBUG log generated by main() function');
$logger->info('this is an INFO log generated by main() function');
$logger->warn('this is a WARN log generated by main() function');
$logger->error('this is an ERROR log generated by main() function');
$logger->fatal('this is a FATAL log generated by main() function');                                


$test = new Test();
$test->testLog();

$testTest = new TestTest();
$testTest->testLog();

//test Bar
Bar();

?>