本文整理汇总了PHP中Logger::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::getName方法的具体用法?PHP Logger::getName怎么用?PHP Logger::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::getName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstruct
public function testConstruct()
{
$root = new Logger('root');
$logger = new Logger('logger', $root);
$this->assertEquals('logger', $logger->getName());
$this->assertTrue($root === $logger->getParent());
$this->assertEquals(array(), $logger->getAppenders());
$this->assertTrue($logger->getAddictive());
}
示例2: testGetSetName
public function testGetSetName()
{
// Using method
$logger = new Logger();
$logger->setName('logger1');
$this->assertEquals('logger1', $logger->getName());
// Using constructor
$logger2 = new Logger(null, 'logger2');
$this->assertEquals('logger2', $logger2->getName());
}
示例3: test_constructor_Monolog
public function test_constructor_Monolog()
{
$log = new Logger();
$this->assertTrue($log instanceof Logger);
$this->assertEquals(Logger::DEFAULT_LOGGER_NAME, $log->getName());
$this->assertTrue($log->isMonologLogger());
$logTest = Logger::instance('test');
$this->assertEquals('test', $logTest->getName());
$this->assertTrue($log->isMonologLogger());
$logMage = Logger::instance('magento', 'some/file/that/is/not/exist');
$this->assertEquals('magento', $logMage->getName());
$this->assertFalse($logMage->isMonologLogger());
}
示例4: toString
/**
* String representation of this log record
*
* @return string
*/
public function toString()
{
// Date & Level
$msg = '[' . $this->getTimeFormat() . ' ' . $this->getLevelName();
// Name
if ($this->logger->getDisplaysName()) {
$msg .= ' ' . $this->logger->getName();
}
$msg .= '] ';
// Message
if ($this->message) {
$msg .= $this->message . ' ';
}
if ($this->thrown) {
$msg .= ABException::format($this->thrown, true, false);
}
return "{$msg}";
}
示例5: printHierarchyInner
private function printHierarchyInner(Logger $current, $level)
{
for ($i = 0; $i < $level; $i++) {
echo $i == $level - 1 ? "|--" : "| ";
}
echo $current->getName() . "\n";
foreach ($this->loggers as $logger) {
if ($logger->getParent() == $current) {
$this->printHierarchyInner($logger, $level + 1);
}
}
}
示例6: setProcessorsForLogger
/**
* Appends the processors to the given logger as configured.
*
* @param \TYPO3\CMS\Core\Log\Logger $logger Logger to configure
* @return void
*/
protected function setProcessorsForLogger(Logger $logger)
{
$configuration = $this->getConfigurationForLogger(self::CONFIGURATION_TYPE_PROCESSOR, $logger->getName());
foreach ($configuration as $severityLevel => $processor) {
foreach ($processor as $logProcessorClassName => $logProcessorOptions) {
/** @var $logProcessor \TYPO3\CMS\Core\Log\Processor\ProcessorInterface */
$logProcessor = NULL;
try {
$logProcessor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($logProcessorClassName, $logProcessorOptions);
$logger->addProcessor($severityLevel, $logProcessor);
} catch (\Psr\Log\InvalidArgumentException $e) {
$logger->warning('Instantiation of LogProcessor "' . $logProcessorClassName . '" failed for logger ' . $logger->getName() . ' (' . $e->getMessage() . ')');
} catch (\TYPO3\CMS\Core\Log\Exception\InvalidLogProcessorConfigurationException $e) {
$logger->warning('Instantiation of LogProcessor "' . $logProcessorClassName . '" failed for logger ' . $logger->getName() . ' (' . $e->getMessage() . ')');
}
}
}
}
示例7: testGetName
/**
* @return void
*/
public function testGetName()
{
$someName = 'Some name';
$logger = new Logger($someName);
$this->assertEquals($someName, $logger->getName());
}
示例8: configureLogger
/**
* Configures a logger.
*
* @param Logger $logger The logger to configure
* @param array $config Logger configuration options.
*/
private function configureLogger(Logger $logger, $config)
{
$loggerName = $logger->getName();
// Set logger level
if (isset($config['level'])) {
$level = LoggerLevel::toLevel($config['level']);
if (isset($level)) {
$logger->setLevel($level);
} else {
$default = $logger->getLevel();
$this->warn("Invalid level value [{$config['level']}] specified for logger [{$loggerName}]. Ignoring level definition.");
}
}
// Link appenders to logger
if (isset($config['appenders'])) {
foreach ($config['appenders'] as $appenderName) {
if (isset($this->appenders[$appenderName])) {
$logger->addAppender($this->appenders[$appenderName]);
} else {
$this->warn("Nonexistnant appender [{$appenderName}] linked to logger [{$loggerName}].");
}
}
}
// Set logger additivity
if (isset($config['additivity'])) {
$additivity = LoggerOptionConverter::toBoolean($config['additivity'], null);
if (is_bool($additivity)) {
$logger->setAdditivity($additivity);
} else {
$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [{$loggerName}]. Ignoring additivity setting.");
}
}
}