Blame | Letzte Änderung | Log anzeigen | RSS feed
--TEST--Log: Composite Handler--INI--date.timezone=UTC--FILE--<?phprequire_once 'Log.php';function printOpenStates($children) {foreach ($children as $child) {$state = ($child->_opened) ? 'OPEN' : 'CLOSED';echo "$child->_ident : $state\n";}}function printIdents($children) {foreach ($children as $child) {echo "$child->_ident\n";}}function testPriority($composite, $priority) {$name = Log::priorityToString($priority);$success = $composite->log($name, $priority);echo "$name : " . (($success) ? 'GOOD' : 'BAD') . "\n";}/* Create three handlers with different priority masks. */$conf = array('lineFormat' => '%2$s [%3$s] %4$s');$children = array(Log::singleton('console', '', 'CONSOLE1', $conf),Log::singleton('console', '', 'CONSOLE2', $conf),Log::singleton('console', '', 'CONSOLE3', $conf));$children[0]->setMask(Log::MASK(PEAR_LOG_DEBUG));$children[1]->setMask(Log::MASK(PEAR_LOG_INFO));$children[2]->setMask(Log::MASK(PEAR_LOG_ERR));$composite = Log::singleton('composite');$composite->addChild($children[0]);$composite->addChild($children[1]);$composite->addChild($children[2]);/* Verify that all of the children are initially closed. */printOpenStates($children);/* Verify that the composite handler's open() opens all of the children. */$composite->open();printOpenStates($children);/* Verify that the composite handler's close() closes all of the children. */$composite->close();printOpenStates($children);/* Verify the log results at different priorities. */testPriority($composite, PEAR_LOG_DEBUG);printOpenStates($children);testPriority($composite, PEAR_LOG_INFO);printOpenStates($children);testPriority($composite, PEAR_LOG_ERR);printOpenStates($children);/* Verify that changing the ident affects all children. */$composite->setIdent('IDENT');printIdents($children);--EXPECT--CONSOLE1 : CLOSEDCONSOLE2 : CLOSEDCONSOLE3 : CLOSEDCONSOLE1 : OPENCONSOLE2 : OPENCONSOLE3 : OPENCONSOLE1 : CLOSEDCONSOLE2 : CLOSEDCONSOLE3 : CLOSEDCONSOLE1 [debug] debugdebug : GOODCONSOLE1 : OPENCONSOLE2 : CLOSEDCONSOLE3 : CLOSEDCONSOLE2 [info] infoinfo : GOODCONSOLE1 : OPENCONSOLE2 : OPENCONSOLE3 : CLOSEDCONSOLE3 [error] errorerror : GOODCONSOLE1 : OPENCONSOLE2 : OPENCONSOLE3 : OPENIDENTIDENTIDENT