本文整理汇总了PHP中Logger::getHierarchy方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::getHierarchy方法的具体用法?PHP Logger::getHierarchy怎么用?PHP Logger::getHierarchy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::getHierarchy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddRenderer
public function testAddRenderer()
{
$hierarchy = Logger::getHierarchy();
//print_r($hierarchy);
LoggerRendererMap::addRenderer($hierarchy, 'string', 'LoggerRendererDefault');
//print_r($hierarchy);
self::markTestIncomplete();
}
示例2: testGetByClassName
public function testGetByClassName()
{
Logger::configure(dirname(__FILE__) . '/test4.properties');
$hierarchy = Logger::getHierarchy();
$map = $hierarchy->getRendererMap();
$e = $map->getByClassName('Fruit3');
self::assertTrue($e instanceof FruitRenderer3);
}
示例3: getStringRepresentation
/**
* @desc Returns string representation of throwable
*
* @return array
*/
public function getStringRepresentation()
{
if (!is_array($this->throwableArray)) {
$renderer = Logger::getHierarchy()->getRendererMap()->getByClassName(get_class($this->throwable));
// TODO: why this?
if ($renderer instanceof LoggerRendererDefault) {
$renderer = new LoggerRendererException();
}
$this->throwableArray = explode("\n", $renderer->render($this->throwable));
}
return $this->throwableArray;
}
示例4: testGetLocationInformation
public function testGetLocationInformation()
{
$hierarchy = Logger::getHierarchy();
$root = $hierarchy->getRootLogger();
$a = new LoggerLoggingEventTestCaseAppender('A1');
$a->setLayout(new LoggerLoggingEventTestCaseLayout());
$root->addAppender($a);
$logger = $hierarchy->getLogger('test');
$line = __LINE__;
$logger->debug('test');
$hierarchy->shutdown();
$li = self::$locationInfo;
self::assertEquals($li->getClassName(), get_class($this));
self::assertEquals($li->getFileName(), __FILE__);
self::assertEquals($li->getLineNumber(), $line);
self::assertEquals($li->getMethodName(), __FUNCTION__);
}
示例5: testThreshold
public function testThreshold()
{
Logger::configure(array('threshold' => 'WARN', 'rootLogger' => array('appenders' => array('default')), 'appenders' => array('default' => array('class' => 'LoggerAppenderEcho'))));
$actual = Logger::getHierarchy()->getThreshold();
$expected = LoggerLevel::getLevelWarn();
self::assertSame($expected, $actual);
}
示例6: testGetThrowableInformation2
public function testGetThrowableInformation2()
{
$hierarchy = Logger::getHierarchy();
$root = $hierarchy->getRootLogger();
$a = new LoggerLoggingEventTestCaseAppender('A1');
$a->setLayout(new LoggerLoggingEventTestCaseLayout());
$root->addAppender($a);
$ex = new Exception('Message1');
$logger = $hierarchy->getLogger('test');
$logger->debug('test', $ex);
$hierarchy->shutdown();
$ti = self::$throwableInfo;
self::assertTrue($ti instanceof LoggerThrowableInformation);
$result = $ti->getStringRepresentation();
self::assertInternalType('array', $result);
}
示例7: getRenderedMessage
/**
* Render message.
* @return string
*/
public function getRenderedMessage()
{
if ($this->renderedMessage === null and $this->message !== null) {
if (is_string($this->message)) {
$this->renderedMessage = $this->message;
} else {
$rendererMap = Logger::getHierarchy()->getRendererMap();
$this->renderedMessage = $rendererMap->findAndRender($this->message);
}
}
return $this->renderedMessage;
}
示例8: getRenderedMessage
/**
* Render message.
* @return string
*/
public function getRenderedMessage()
{
if ($this->renderedMessage === null and $this->message !== null) {
if (is_string($this->message)) {
$this->renderedMessage = $this->message;
} else {
// $this->logger might be null or an instance of Logger or RootLogger
// But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is
// no need figure out which one is $this->logger part of.
// TODO: Logger::getHierarchy() is marked @deprecated!
$repository = Logger::getHierarchy();
$rendererMap = $repository->getRendererMap();
$this->renderedMessage = $rendererMap->findAndRender($this->message);
}
}
return $this->renderedMessage;
}
示例9: testRenderer
public function testRenderer()
{
Logger::configure('configurators/test4.properties');
Logger::initialize();
$hierarchy = Logger::getHierarchy();
$map = $hierarchy->getRendererMap();
$clazz = $map->getByClassName('Fruit');
self::assertTrue($clazz instanceof FruitRenderer);
}
示例10: testXMLConfig
public function testXMLConfig()
{
$map = Logger::getHierarchy()->getRendererMap();
Logger::resetConfiguration();
self::assertInstanceOf('LoggerRendererDefault', $map->getDefaultRenderer());
Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_default_renderer.xml');
self::assertInstanceOf('FruitRenderer3', $map->getDefaultRenderer());
Logger::resetConfiguration();
self::assertInstanceOf('LoggerRendererDefault', $map->getDefaultRenderer());
}
示例11: testThreshold
public function testThreshold()
{
Logger::configure('configurators/test1.xml');
$root = Logger::getRootLogger();
self::assertEquals(LoggerLevel::getLevelWarn(), $root->getLevel());
$appender = $root->getAppender("default");
self::assertTrue($appender instanceof LoggerAppenderEcho);
$layout = $appender->getLayout();
self::assertTrue($layout instanceof LoggerLayoutSimple);
$threshold = $appender->getThreshold();
self::assertTrue($threshold instanceof LoggerLevel);
$e = LoggerLevel::getLevelWarn();
self::assertEquals($e, $threshold);
$appender = $root->getAppender("blub");
self::assertTrue($appender instanceof LoggerAppenderEcho);
$layout = $appender->getLayout();
self::assertTrue($layout instanceof LoggerLayoutSimple);
$threshold = $appender->getThreshold();
self::assertTrue($threshold instanceof LoggerLevel);
$e = LoggerLevel::getLevelInfo();
self::assertEquals($e, $threshold);
$filter = $appender->getFilter();
self::assertTrue($filter instanceof LoggerFilterLevelRange);
$filter2 = $filter->getNext();
self::assertTrue($filter2 instanceof LoggerFilterDenyAll);
$threshold = Logger::getHierarchy()->getThreshold();
self::assertTrue($threshold instanceof LoggerLevel);
$e = LoggerLevel::getLevelWarn();
self::assertEquals($e, $threshold);
$hierarchy = Logger::getHierarchy();
$map = $hierarchy->getRendererMap();
$clazz = $map->getByClassName('Fruit2');
self::assertTrue($clazz instanceof FruitRenderer2);
}