本文整理汇总了PHP中LoggerOptionConverter::toBoolean方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerOptionConverter::toBoolean方法的具体用法?PHP LoggerOptionConverter::toBoolean怎么用?PHP LoggerOptionConverter::toBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerOptionConverter
的用法示例。
在下文中一共展示了LoggerOptionConverter::toBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToBoolean
public function testToBoolean()
{
self::assertTrue(LoggerOptionConverter::toBoolean(null, true));
self::assertTrue(LoggerOptionConverter::toBoolean('foo', true));
self::assertTrue(LoggerOptionConverter::toBoolean(null));
self::assertTrue(LoggerOptionConverter::toBoolean(true));
self::assertTrue(LoggerOptionConverter::toBoolean("1"));
self::assertTrue(LoggerOptionConverter::toBoolean(1));
self::assertTrue(LoggerOptionConverter::toBoolean("true"));
self::assertTrue(LoggerOptionConverter::toBoolean("on"));
self::assertTrue(LoggerOptionConverter::toBoolean("yes"));
self::assertFalse(LoggerOptionConverter::toBoolean(null, false));
self::assertFalse(LoggerOptionConverter::toBoolean('foo', false));
self::assertFalse(LoggerOptionConverter::toBoolean(false));
self::assertFalse(LoggerOptionConverter::toBoolean(""));
self::assertFalse(LoggerOptionConverter::toBoolean("0"));
self::assertFalse(LoggerOptionConverter::toBoolean(0));
self::assertFalse(LoggerOptionConverter::toBoolean("false"));
self::assertFalse(LoggerOptionConverter::toBoolean("off"));
self::assertFalse(LoggerOptionConverter::toBoolean("no"));
self::assertTrue(LoggerOptionConverter::toBooleanEx(1));
self::assertTrue(LoggerOptionConverter::toBooleanEx("1"));
self::assertTrue(LoggerOptionConverter::toBooleanEx(true));
self::assertTrue(LoggerOptionConverter::toBooleanEx("true"));
self::assertTrue(LoggerOptionConverter::toBooleanEx("on"));
self::assertTrue(LoggerOptionConverter::toBooleanEx("yes"));
self::assertFalse(LoggerOptionConverter::toBooleanEx(0));
self::assertFalse(LoggerOptionConverter::toBooleanEx("0"));
self::assertFalse(LoggerOptionConverter::toBooleanEx(false));
self::assertFalse(LoggerOptionConverter::toBooleanEx("false"));
self::assertFalse(LoggerOptionConverter::toBooleanEx("off"));
self::assertFalse(LoggerOptionConverter::toBooleanEx("no"));
}
示例2: testToBoolean
public function testToBoolean()
{
self::assertEquals(true, LoggerOptionConverter::toBoolean(null, true));
self::assertEquals(true, LoggerOptionConverter::toBoolean(null));
self::assertEquals(true, LoggerOptionConverter::toBoolean(true));
self::assertEquals(true, LoggerOptionConverter::toBoolean("1"));
self::assertEquals(true, LoggerOptionConverter::toBoolean("true"));
self::assertEquals(true, LoggerOptionConverter::toBoolean("on"));
self::assertEquals(true, LoggerOptionConverter::toBoolean("yes"));
self::assertEquals(false, LoggerOptionConverter::toBoolean(null, false));
self::assertEquals(false, LoggerOptionConverter::toBoolean(false));
self::assertEquals(false, LoggerOptionConverter::toBoolean(""));
self::assertEquals(false, LoggerOptionConverter::toBoolean("0"));
self::assertEquals(false, LoggerOptionConverter::toBoolean("false"));
self::assertEquals(false, LoggerOptionConverter::toBoolean("off"));
self::assertEquals(false, LoggerOptionConverter::toBoolean("no"));
}
示例3: parseAdditivityForLogger
/**
* Parse the additivity option for a non-root category.
*
* @param array $props array of properties
* @param Logger &$cat
* @param string $loggerName
*/
function parseAdditivityForLogger($props, &$cat, $loggerName)
{
$value = LoggerOptionConverter::findAndSubst(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName, $props);
LoggerLog::debug("LoggerPropertyConfigurator::parseAdditivityForLogger() " . "Handling " . LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX . $loggerName . "=[{$value}]");
// touch additivity only if necessary
if (!empty($value)) {
$additivity = LoggerOptionConverter::toBoolean($value, true);
LoggerLog::debug("LoggerPropertyConfigurator::parseAdditivityForLogger() " . "Setting additivity for [{$loggerName}] to [{$additivity}]");
$cat->setAdditivity($additivity);
}
}
示例4: setAcceptOnMatch
/**
* @param boolean $acceptOnMatch
*/
public function setAcceptOnMatch($acceptOnMatch)
{
$this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true);
}
示例5: setUseXml
/**
* @param mixed
*/
function setUseXml($flag)
{
$this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml());
}
示例6: tagOpen
/**
* @param mixed $parser
* @param string $tag
* @param array $attribs
*
* @todo In 'LOGGER' case find a better way to detect 'getLogger()' method
*/
private function tagOpen($parser, $tag, $attribs)
{
switch ($tag) {
case 'CONFIGURATION':
case self::XMLNS . ':CONFIGURATION':
if (isset($attribs['THRESHOLD'])) {
$this->repository->setThreshold(LoggerOptionConverter::toLevel($this->subst($attribs['THRESHOLD']), $this->repository->getThreshold()));
}
break;
case 'APPENDER':
case self::XMLNS . ':APPENDER':
unset($this->appender);
$this->appender = null;
$name = $this->subst(@$attribs['NAME']);
$class = $this->subst(@$attribs['CLASS']);
$this->appender = LoggerAppenderPool::getAppenderFromPool($name, $class);
if (isset($attribs['THRESHOLD'])) {
$this->appender->setThreshold(LoggerOptionConverter::toLevel($this->subst($attribs['THRESHOLD']), $this->appender->getThreshold()));
}
$this->state[] = self::APPENDER_STATE;
break;
case 'APPENDER_REF':
case 'APPENDER-REF':
case self::XMLNS . ':APPENDER_REF':
case self::XMLNS . ':APPENDER-REF':
if (isset($attribs['REF']) and !empty($attribs['REF'])) {
$appenderName = $this->subst($attribs['REF']);
$appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
if ($appender !== null) {
switch (end($this->state)) {
case self::LOGGER_STATE:
case self::ROOT_STATE:
$this->logger->addAppender($appender);
break;
}
}
}
break;
case 'FILTER':
case self::XMLNS . ':FILTER':
unset($this->filter);
$this->filter = null;
$filterName = basename($this->subst(@$attribs['CLASS']));
if (!empty($filterName)) {
$this->filter = new $filterName();
$this->state[] = self::FILTER_STATE;
}
break;
case 'LAYOUT':
case self::XMLNS . ':LAYOUT':
$class = @$attribs['CLASS'];
$this->layout = LoggerReflectionUtils::createObject($this->subst($class));
$this->state[] = self::LAYOUT_STATE;
break;
case 'LOGGER':
case self::XMLNS . ':LOGGER':
// $this->logger is assigned by reference.
// Only '$this->logger=null;' destroys referenced object
unset($this->logger);
$this->logger = null;
$loggerName = $this->subst(@$attribs['NAME']);
if (!empty($loggerName)) {
$this->logger = $this->repository->getLogger($loggerName);
if ($this->logger !== null and isset($attribs['ADDITIVITY'])) {
$additivity = LoggerOptionConverter::toBoolean($this->subst($attribs['ADDITIVITY']), true);
$this->logger->setAdditivity($additivity);
}
}
$this->state[] = self::LOGGER_STATE;
break;
case 'LEVEL':
case self::XMLNS . ':LEVEL':
case 'PRIORITY':
case self::XMLNS . ':PRIORITY':
if (!isset($attribs['VALUE'])) {
// LoggerDOMConfigurator::tagOpen() LEVEL value not set
break;
}
if ($this->logger === null) {
// LoggerDOMConfigurator::tagOpen() LEVEL. parent logger is null
break;
}
switch (end($this->state)) {
case self::ROOT_STATE:
$this->logger->setLevel(LoggerOptionConverter::toLevel($this->subst($attribs['VALUE']), $this->logger->getLevel()));
break;
case self::LOGGER_STATE:
$this->logger->setLevel(LoggerOptionConverter::toLevel($this->subst($attribs['VALUE']), $this->logger->getLevel()));
break;
default:
//LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL state '{$this->state}' not allowed here");
}
break;
//.........这里部分代码省略.........
示例7: setCreateTable
function setCreateTable($flag)
{
$this->createTable = LoggerOptionConverter::toBoolean($flag, true);
}
示例8: parseAdditivityForLogger
/**
* Parse the additivity option for a non-root category.
*
* @param array $props array of properties
* @param Logger $cat
* @param string $loggerName
*/
private function parseAdditivityForLogger($props, Logger $cat, $loggerName)
{
$value = LoggerOptionConverter::findAndSubst(self::ADDITIVITY_PREFIX . $loggerName, $props);
// touch additivity only if necessary
if (!empty($value)) {
$additivity = LoggerOptionConverter::toBoolean($value, true);
$cat->setAdditivity($additivity);
}
}
示例9: setLog4jNamespace
/**
* @param boolean
*/
public function setLog4jNamespace($flag)
{
$this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, true);
}
示例10: setAppend
function setAppend($flag)
{
$this->append = LoggerOptionConverter::toBoolean($flag, true);
}
示例11: 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.");
}
}
}
示例12: define
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
if (!defined('LOG4PHP_DEFAULT_INIT_OVERRIDE')) {
if (isset($_ENV['log4php.defaultInitOverride'])) {
/**
* @ignore
*/
define('LOG4PHP_DEFAULT_INIT_OVERRIDE', LoggerOptionConverter::toBoolean($_ENV['log4php.defaultInitOverride'], false));
} elseif (isset($GLOBALS['log4php.defaultInitOverride'])) {
/**
* @ignore
*/
define('LOG4PHP_DEFAULT_INIT_OVERRIDE', LoggerOptionConverter::toBoolean($GLOBALS['log4php.defaultInitOverride'], false));
} else {
/**
* Controls init execution
*
* With this constant users can skip the default init procedure that is
* called when this file is included.
*
* <p>If it is not user defined, log4php tries to autoconfigure using (in order):</p>
*
* - the <code>$_ENV['log4php.defaultInitOverride']</code> variable.
* - the <code>$GLOBALS['log4php.defaultInitOverride']</code> global variable.
* - defaults to <i>false</i>
*
* @var boolean
*/
示例13: setContextPrinting
/**
* The <b>ContextPrinting</b> option specifies log output will include
* the nested context information belonging to the current thread.
* This is true by default.
*/
public function setContextPrinting($contextPrinting)
{
$this->contextPrinting = LoggerOptionConverter::toBoolean($contextPrinting);
}
示例14: tagOpen
/**
* @param mixed $parser
* @param string $tag
* @param array $attribs
*
* @todo In 'LOGGER' case find a better way to detect 'getLogger()' method
*/
function tagOpen($parser, $tag, $attribs)
{
switch ($tag) {
case 'CONFIGURATION':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':CONFIGURATION':
LoggerLog::debug("LoggerDOMConfigurator::tagOpen() CONFIGURATION");
if (isset($attribs['THRESHOLD'])) {
$this->repository->setThreshold(LoggerOptionConverter::toLevel($this->subst($attribs['THRESHOLD']), $this->repository->getThreshold()));
}
if (isset($attribs['DEBUG'])) {
$debug = LoggerOptionConverter::toBoolean($this->subst($attribs['DEBUG']), LoggerLog::internalDebugging());
$this->repository->debug = $debug;
LoggerLog::internalDebugging($debug);
LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOG4PHP:CONFIGURATION. Internal Debug turned " . ($debug ? 'on' : 'off'));
}
break;
case 'APPENDER':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':APPENDER':
unset($this->appender);
$this->appender = null;
$name = $this->subst(@$attribs['NAME']);
$class = $this->subst(@$attribs['CLASS']);
LoggerLog::debug("LoggerDOMConfigurator::tagOpen():tag=[{$tag}]:name=[{$name}]:class=[{$class}]");
$this->appender =& LoggerAppender::singleton($name, $class);
if ($this->appender === null) {
LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER cannot instantiate appender '{$name}'");
}
$this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE;
break;
case 'APPENDER_REF':
case 'APPENDER-REF':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':APPENDER_REF':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':APPENDER-REF':
if (isset($attribs['REF']) and !empty($attribs['REF'])) {
$appenderName = $this->subst($attribs['REF']);
LoggerLog::debug("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref='{$appenderName}'");
$appender =& LoggerAppender::singleton($appenderName);
if ($appender !== null) {
switch (end($this->state)) {
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LOGGER_STATE:
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_ROOT_STATE:
$this->logger->addAppender($appender);
break;
}
} else {
LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref '{$appenderName}' points to a null appender");
}
} else {
LoggerLog::warn("LoggerDOMConfigurator::tagOpen() APPENDER-REF ref not set or empty");
}
break;
case 'FILTER':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':FILTER':
LoggerLog::debug("LoggerDOMConfigurator::tagOpen() FILTER");
unset($this->filter);
$this->filter = null;
$filterName = basename($this->subst(@$attribs['CLASS']));
if (!empty($filterName)) {
if (!class_exists($filterName)) {
@(include_once LOG4PHP_DIR . "/varia/{$filterName}.php");
}
if (class_exists($filterName)) {
$this->filter = new $filterName();
} else {
LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER. class '{$filterName}' doesnt exist");
}
$this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE;
} else {
LoggerLog::warn("LoggerDOMConfigurator::tagOpen() FILTER filter name cannot be empty");
}
break;
case 'LAYOUT':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':LAYOUT':
$class = @$attribs['CLASS'];
LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LAYOUT class='{$class}'");
$this->layout = LoggerLayout::factory($this->subst($class));
if ($this->layout === null) {
LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LAYOUT unable to instanciate class='{$class}'");
}
$this->state[] = LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE;
break;
case 'LOGGER':
case LOG4PHP_LOGGER_DOM_CONFIGURATOR_XMLNS . ':LOGGER':
// $this->logger is assigned by reference.
// Only '$this->logger=null;' destroys referenced object
unset($this->logger);
$this->logger = null;
$loggerName = $this->subst(@$attribs['NAME']);
if (!empty($loggerName)) {
LoggerLog::debug("LoggerDOMConfigurator::tagOpen() LOGGER. name='{$loggerName}'");
$class = $this->subst(@$attribs['CLASS']);
if (empty($class)) {
$this->logger =& $this->repository->getLogger($loggerName);
//.........这里部分代码省略.........
示例15: setHtmlLineBreaks
public function setHtmlLineBreaks($value)
{
$this->htmlLineBreaks = LoggerOptionConverter::toBoolean($value, false);
}