You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by ku...@apache.org on 2009/05/01 09:58:55 UTC
svn commit: r770568 - in /incubator/log4php/trunk/src/main/php: ./ varia/
Author: kurdalen
Date: Fri May 1 07:58:54 2009
New Revision: 770568
URL: http://svn.apache.org/viewvc?rev=770568&view=rev
Log:
more code style fixes
Modified:
incubator/log4php/trunk/src/main/php/Logger.php
incubator/log4php/trunk/src/main/php/LoggerAppender.php
incubator/log4php/trunk/src/main/php/LoggerAppenderSkeleton.php
incubator/log4php/trunk/src/main/php/LoggerBasicConfigurator.php
incubator/log4php/trunk/src/main/php/LoggerDefaultCategoryFactory.php
incubator/log4php/trunk/src/main/php/LoggerHierarchy.php
incubator/log4php/trunk/src/main/php/LoggerLayout.php
incubator/log4php/trunk/src/main/php/LoggerLevel.php
incubator/log4php/trunk/src/main/php/LoggerLog.php
incubator/log4php/trunk/src/main/php/LoggerMDC.php
incubator/log4php/trunk/src/main/php/LoggerManager.php
incubator/log4php/trunk/src/main/php/LoggerNDC.php
incubator/log4php/trunk/src/main/php/LoggerPropertyConfigurator.php
incubator/log4php/trunk/src/main/php/LoggerRoot.php
incubator/log4php/trunk/src/main/php/varia/LoggerDenyAllFilter.php
incubator/log4php/trunk/src/main/php/varia/LoggerLevelMatchFilter.php
incubator/log4php/trunk/src/main/php/varia/LoggerLevelRangeFilter.php
incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php
Modified: incubator/log4php/trunk/src/main/php/Logger.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/Logger.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/Logger.php (original)
+++ incubator/log4php/trunk/src/main/php/Logger.php Fri May 1 07:58:54 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,571 +17,524 @@
*
* @category log4php
* @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version SVN: $Id$
- * @link http://logging.apache.org/log4php
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @version SVN: $Id$
+ * @link http://logging.apache.org/log4php
*/
/**
* This class has been deprecated and replaced by the Logger subclass.
*
- * @version $Revision$
+ * @version $Revision$
* @package log4php
* @see Logger
*/
class Logger {
- /**
- * Additivity is set to true by default, that is children inherit the
- * appenders of their ancestors by default.
- * @var boolean
- */
- protected $additive = true;
-
- /**
- * @var string fully qualified class name
- */
- protected $fqcn = 'LoggerCategory';
-
- /**
- * @var LoggerLevel The assigned level of this category.
- */
- var $level = null;
-
- /**
- * @var string name of this category.
- */
- protected $name = '';
-
- /**
- * @var Logger The parent of this category.
- */
- protected $parent = null;
-
- /**
- * @var LoggerHierarchy the object repository
- */
- var $repository = null;
-
- /**
- * @var array collection of appenders
- * @see LoggerAppender
- */
- var $aai = array();
-
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-/* --------------------------------------------------------------------------*/
-
- /**
- * Constructor.
- *
- * @param string $name Category name
- */
- public function __construct($name)
- {
- $this->name = $name;
- }
-
- /**
- * Add a new Appender to the list of appenders of this Category instance.
- *
- * @param LoggerAppender $newAppender
- */
- public function addAppender($newAppender)
- {
- $appenderName = $newAppender->getName();
- $this->aai[$appenderName] = $newAppender;
- }
-
- /**
- * If assertion parameter is false, then logs msg as an error statement.
- *
- * @param bool $assertion
- * @param string $msg message to log
- */
- public function assertLog($assertion = true, $msg = '')
- {
- if ($assertion == false) {
- $this->error($msg);
- }
- }
-
- /**
- * Call the appenders in the hierarchy starting at this.
- *
- * @param LoggerLoggingEvent $event
- */
- public function callAppenders($event)
- {
- if (sizeof($this->aai) > 0) {
- foreach (array_keys($this->aai) as $appenderName) {
- $this->aai[$appenderName]->doAppend($event);
- }
- }
- if ($this->parent != null and $this->getAdditivity()) {
- $this->parent->callAppenders($event);
- }
- }
-
- /**
- * Log a message object with the DEBUG level including the caller.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- public function debug($message, $caller = null)
- {
- $debugLevel = LoggerLevel::getLevelDebug();
- if ($this->repository->isDisabled($debugLevel)) {
- return;
- }
- if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $debugLevel, $message);
- }
- }
-
- /**
- * Log a message object with the ERROR level including the caller.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- public function error($message, $caller = null)
- {
- $errorLevel = LoggerLevel::getLevelError();
- if ($this->repository->isDisabled($errorLevel)) {
- return;
- }
- if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $errorLevel, $message);
- }
- }
-
- /**
- * Deprecated. Please use LoggerManager::exists() instead.
- *
- * @param string $name
- * @see LoggerManager::exists()
- * @deprecated
- */
- public function exists($name)
- {
- return LoggerManager::exists($name);
- }
-
- /**
- * Log a message object with the FATAL level including the caller.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- public function fatal($message, $caller = null)
- {
- $fatalLevel = LoggerLevel::getLevelFatal();
- if ($this->repository->isDisabled($fatalLevel)) {
- return;
- }
- if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message);
- }
- }
-
- /**
- * This method creates a new logging event and logs the event without further checks.
- *
- * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()},
- * {@link error()} and {@link fatal()} wrappers.
- *
- * @param string $fqcn Fully Qualified Class Name of the Logger
- * @param mixed $caller caller object or caller string id
- * @param LoggerLevel $level log level
- * @param mixed $message message
- * @see LoggerLoggingEvent
- */
- public function forcedLog($fqcn, $caller, $level, $message)
- {
- // $fqcn = is_object($caller) ? get_class($caller) : (string)$caller;
- $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message));
- }
-
- /**
- * Get the additivity flag for this Category instance.
- * @return boolean
- */
- public function getAdditivity()
- {
- return $this->additive;
- }
+ /**
+ * Additivity is set to true by default, that is children inherit the
+ * appenders of their ancestors by default.
+ * @var boolean
+ */
+ protected $additive = true;
+
+ /**
+ * @var string fully qualified class name
+ */
+ protected $fqcn = 'LoggerCategory';
+
+ /**
+ * @var LoggerLevel The assigned level of this category.
+ */
+ var $level = null;
+
+ /**
+ * @var string name of this category.
+ */
+ protected $name = '';
+
+ /**
+ * @var Logger The parent of this category.
+ */
+ protected $parent = null;
+
+ /**
+ * @var LoggerHierarchy the object repository
+ */
+ var $repository = null;
+
+ /**
+ * @var array collection of appenders
+ * @see LoggerAppender
+ */
+ var $aai = array();
+
+ /**
+ * Constructor.
+ *
+ * @param string $name Category name
+ */
+ public function __construct($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Add a new Appender to the list of appenders of this Category instance.
+ *
+ * @param LoggerAppender $newAppender
+ */
+ public function addAppender($newAppender) {
+ $appenderName = $newAppender->getName();
+ $this->aai[$appenderName] = $newAppender;
+ }
+
+ /**
+ * If assertion parameter is false, then logs msg as an error statement.
+ *
+ * @param bool $assertion
+ * @param string $msg message to log
+ */
+ public function assertLog($assertion = true, $msg = '') {
+ if($assertion == false) {
+ $this->error($msg);
+ }
+ }
+
+ /**
+ * Call the appenders in the hierarchy starting at this.
+ *
+ * @param LoggerLoggingEvent $event
+ */
+ public function callAppenders($event) {
+ if(sizeof($this->aai) > 0) {
+ foreach(array_keys($this->aai) as $appenderName) {
+ $this->aai[$appenderName]->doAppend($event);
+ }
+ }
+ if($this->parent != null and $this->getAdditivity()) {
+ $this->parent->callAppenders($event);
+ }
+ }
+
+ /**
+ * Log a message object with the DEBUG level including the caller.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ public function debug($message, $caller = null) {
+ $debugLevel = LoggerLevel::getLevelDebug();
+ if($this->repository->isDisabled($debugLevel)) {
+ return;
+ }
+ if($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $debugLevel, $message);
+ }
+ }
+
+ /**
+ * Log a message object with the ERROR level including the caller.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ public function error($message, $caller = null) {
+ $errorLevel = LoggerLevel::getLevelError();
+ if($this->repository->isDisabled($errorLevel)) {
+ return;
+ }
+ if($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $errorLevel, $message);
+ }
+ }
+
+ /**
+ * Deprecated. Please use LoggerManager::exists() instead.
+ *
+ * @param string $name
+ * @see LoggerManager::exists()
+ * @deprecated
+ */
+ public function exists($name) {
+ return LoggerManager::exists($name);
+ }
+
+ /**
+ * Log a message object with the FATAL level including the caller.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ public function fatal($message, $caller = null) {
+ $fatalLevel = LoggerLevel::getLevelFatal();
+ if($this->repository->isDisabled($fatalLevel)) {
+ return;
+ }
+ if($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message);
+ }
+ }
+
+ /**
+ * This method creates a new logging event and logs the event without further checks.
+ *
+ * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()},
+ * {@link error()} and {@link fatal()} wrappers.
+ *
+ * @param string $fqcn Fully Qualified Class Name of the Logger
+ * @param mixed $caller caller object or caller string id
+ * @param LoggerLevel $level log level
+ * @param mixed $message message
+ * @see LoggerLoggingEvent
+ */
+ public function forcedLog($fqcn, $caller, $level, $message) {
+ // $fqcn = is_object($caller) ? get_class($caller) : (string)$caller;
+ $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message));
+ }
+
+ /**
+ * Get the additivity flag for this Category instance.
+ * @return boolean
+ */
+ public function getAdditivity() {
+ return $this->additive;
+ }
- /**
- * Get the appenders contained in this category as an array.
- * @return array collection of appenders
- */
- public function getAllAppenders()
- {
- return array_values($this->aai);
- }
-
- /**
- * Look for the appender named as name.
- * @return LoggerAppender
- */
- public function getAppender($name)
- {
- return $this->aai[$name];
- }
-
- /**
- * Please use the {@link getEffectiveLevel()} method instead.
- * @deprecated
- */
- public function getChainedPriority()
- {
- return $this->getEffectiveLevel();
- }
+ /**
+ * Get the appenders contained in this category as an array.
+ * @return array collection of appenders
+ */
+ public function getAllAppenders() {
+ return array_values($this->aai);
+ }
+
+ /**
+ * Look for the appender named as name.
+ * @return LoggerAppender
+ */
+ public function getAppender($name) {
+ return $this->aai[$name];
+ }
+
+ /**
+ * Please use the {@link getEffectiveLevel()} method instead.
+ * @deprecated
+ */
+ public function getChainedPriority() {
+ return $this->getEffectiveLevel();
+ }
- /**
- * Please use {@link LoggerManager::getCurrentLoggers()} instead.
- * @deprecated
- */
- public function getCurrentCategories()
- {
- return LoggerManager::getCurrentLoggers();
- }
+ /**
+ * Please use {@link LoggerManager::getCurrentLoggers()} instead.
+ * @deprecated
+ */
+ public function getCurrentCategories() {
+ return LoggerManager::getCurrentLoggers();
+ }
- /**
- * Please use {@link LoggerManager::getLoggerRepository()} instead.
- * @deprecated
- */
- public function getDefaultHierarchy()
- {
- return LoggerManager::getLoggerRepository();
- }
+ /**
+ * Please use {@link LoggerManager::getLoggerRepository()} instead.
+ * @deprecated
+ */
+ public function getDefaultHierarchy() {
+ return LoggerManager::getLoggerRepository();
+ }
- /**
- * @deprecated Use {@link getLoggerRepository()}
- * @return LoggerHierarchy
- */
- public function getHierarchy()
- {
- return $this->getLoggerRepository();
- }
-
- /**
- * Starting from this category, search the category hierarchy for a non-null level and return it.
- * @see LoggerLevel
- * @return LoggerLevel or null
- */
- public function getEffectiveLevel()
- {
- for($c = $this; $c != null; $c = $c->parent) {
- if($c->getLevel() !== null)
- return $c->getLevel();
- }
- return null;
- }
+ /**
+ * @deprecated Use {@link getLoggerRepository()}
+ * @return LoggerHierarchy
+ */
+ public function getHierarchy() {
+ return $this->getLoggerRepository();
+ }
+
+ /**
+ * Starting from this category, search the category hierarchy for a non-null level and return it.
+ * @see LoggerLevel
+ * @return LoggerLevel or null
+ */
+ public function getEffectiveLevel() {
+ for($c = $this; $c != null; $c = $c->parent) {
+ if($c->getLevel() !== null) {
+ return $c->getLevel();
+ }
+ }
+ return null;
+ }
- /**
- * Retrieve a category with named as the name parameter.
- * @return Logger
- */
- public function getInstance($name)
- {
- return LoggerManager::getLogger($name);
- }
-
- /**
- * Returns the assigned Level, if any, for this Category.
- * @return LoggerLevel or null
- */
- public function getLevel()
- {
- return $this->level;
- }
-
- /**
- * Get a Logger by name (Delegate to {@link LoggerManager})
- * @param string $name logger name
- * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
- * @return Logger
- * @static
- */
- public function getLogger($name, $factory = null)
- {
- return LoggerManager::getLogger($name, $factory);
- }
-
- /**
- * Return the the repository where this Category is attached.
- * @return LoggerHierarchy
- */
- public function getLoggerRepository()
- {
- return $this->repository;
- }
-
- /**
- * Return the category name.
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Returns the parent of this category.
- * @return Logger
- */
- public function getParent()
- {
- return $this->parent;
- }
-
- /**
- * Please use getLevel() instead.
- * @deprecated
- */
- public function getPriority()
- {
- return $this->getLevel();
- }
-
- /**
- * Return the inherited ResourceBundle for this category.
- */
- public function getResourceBundle()
- {
- return;
- }
-
- /**
- * Returns the string resource corresponding to key in this category's inherited resource bundle.
- */
- public function getResourceBundleString($key)
- {
- return;
- }
-
- /**
- * Return the root of the default category hierarchy.
- * @return LoggerRoot
- */
- public function getRoot()
- {
- return LoggerManager::getRootLogger();
- }
-
- /**
- * get the Root Logger (Delegate to {@link LoggerManager})
- * @return LoggerRoot
- * @static
- */
- public function getRootLogger()
- {
- return LoggerManager::getRootLogger();
- }
-
- /**
- * Log a message object with the INFO Level.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- public function info($message, $caller = null)
- {
- $infoLevel = LoggerLevel::getLevelInfo();
- if ($this->repository->isDisabled($infoLevel)) {
- return;
- }
- if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $infoLevel, $message);
- }
- }
-
- /**
- * Is the appender passed as parameter attached to this category?
- *
- * @param LoggerAppender $appender
- */
- public function isAttached($appender)
- {
- return isset($this->aai[$appender->getName()]);
- }
-
- /**
- * Check whether this category is enabled for the DEBUG Level.
- * @return boolean
- */
- public function isDebugEnabled()
- {
- $debugLevel = LoggerLevel::getLevelDebug();
- if ($this->repository->isDisabled($debugLevel)) {
- return false;
- }
- return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel()));
- }
-
- /**
- * Check whether this category is enabled for a given Level passed as parameter.
- *
- * @param LoggerLevel level
- * @return boolean
- */
- public function isEnabledFor($level)
- {
- if ($this->repository->isDisabled($level)) {
- return false;
- }
- return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel()));
- }
-
- /**
- * Check whether this category is enabled for the info Level.
- * @return boolean
- * @see LoggerLevel
- */
- public function isInfoEnabled()
- {
- $infoLevel = LoggerLevel::getLevelInfo();
- if ($this->repository->isDisabled($infoLevel)) {
- return false;
- }
- return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel()));
- }
-
- /**
- * Log a localized and parameterized message.
- */
- public function l7dlog($priority, $key, $params, $t)
- {
- return;
- }
-
- /**
- * This generic form is intended to be used by wrappers.
- *
- * @param LoggerLevel $priority a valid level
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- public function log($priority, $message, $caller = null)
- {
- if ($this->repository->isDisabled($priority)) {
- return;
- }
- if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $priority, $message);
- }
- }
-
- /**
- * Remove all previously added appenders from this Category instance.
- */
- public function removeAllAppenders()
- {
- $appenderNames = array_keys($this->aai);
- $enumAppenders = sizeof($appenderNames);
- for ($i = 0; $i < $enumAppenders; $i++) {
- $this->removeAppender($appenderNames[$i]);
- }
- }
-
- /**
- * Remove the appender passed as parameter form the list of appenders.
- *
- * @param mixed $appender can be an appender name or a {@link LoggerAppender} object
- */
- public function removeAppender($appender)
- {
- if ($appender instanceof LoggerAppender) {
- $appender->close();
- unset($this->aai[$appender->getName()]);
- } elseif (is_string($appender) and isset($this->aai[$appender])) {
- $this->aai[$appender]->close();
- unset($this->aai[$appender]);
- }
- }
-
- /**
- * Set the additivity flag for this Category instance.
- *
- * @param boolean $additive
- */
- public function setAdditivity($additive)
- {
- $this->additive = (bool)$additive;
- }
-
- /**
- * @deprecated Please use {@link setLevel()} instead.
- * @see setLevel()
- */
- public function setPriority($priority)
- {
- $this->setLevel($priority);
- }
-
- /**
- * Only the Hierarchy class can set the hierarchy of a
- * category.
- *
- * @param LoggerHierarchy $repository
- */
- public function setHierarchy($repository)
- {
- $this->repository = $repository;
- }
-
- /**
- * Set the level of this Category.
- *
- * @param LoggerLevel $level a level string or a level constant
- */
- public function setLevel($level)
- {
- $this->level = $level;
- }
-
- public function setParent($logger) {
- if ($logger instanceof Logger) {
- $this->parent = $logger;
- }
- }
-
- /**
- * Set the resource bundle to be used with localized logging methods
- */
- public function setResourceBundle($bundle)
- {
- return;
- }
-
- /**
- * @deprecated use {@link LoggerManager::shutdown()} instead.
- * @see LoggerManager::shutdown()
- */
- public function shutdown()
- {
- LoggerManager::shutdown();
- }
-
- /**
- * Log a message with the WARN level.
- *
- * @param mixed $message message
- * @param mixed $caller caller object or caller string id
- */
- public function warn($message, $caller = null)
- {
- $warnLevel = LoggerLevel::getLevelWarn();
- if ($this->repository->isDisabled($warnLevel)) {
- return;
- }
- if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
- $this->forcedLog($this->fqcn, $caller, $warnLevel, $message);
- }
- }
+ /**
+ * Retrieve a category with named as the name parameter.
+ * @return Logger
+ */
+ public function getInstance($name) {
+ return LoggerManager::getLogger($name);
+ }
+
+ /**
+ * Returns the assigned Level, if any, for this Category.
+ * @return LoggerLevel or null
+ */
+ public function getLevel() {
+ return $this->level;
+ }
+
+ /**
+ * Get a Logger by name (Delegate to {@link LoggerManager})
+ * @param string $name logger name
+ * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
+ * @return Logger
+ * @static
+ */
+ public function getLogger($name, $factory = null) {
+ return LoggerManager::getLogger($name, $factory);
+ }
+
+ /**
+ * Return the the repository where this Category is attached.
+ * @return LoggerHierarchy
+ */
+ public function getLoggerRepository() {
+ return $this->repository;
+ }
+
+ /**
+ * Return the category name.
+ * @return string
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Returns the parent of this category.
+ * @return Logger
+ */
+ public function getParent() {
+ return $this->parent;
+ }
+
+ /**
+ * Please use getLevel() instead.
+ * @deprecated
+ */
+ public function getPriority() {
+ return $this->getLevel();
+ }
+
+ /**
+ * Return the inherited ResourceBundle for this category.
+ */
+ public function getResourceBundle() {
+ return;
+ }
+
+ /**
+ * Returns the string resource corresponding to key in this category's inherited resource bundle.
+ */
+ public function getResourceBundleString($key) {
+ return;
+ }
+
+ /**
+ * Return the root of the default category hierarchy.
+ * @return LoggerRoot
+ */
+ public function getRoot() {
+ return LoggerManager::getRootLogger();
+ }
+
+ /**
+ * get the Root Logger (Delegate to {@link LoggerManager})
+ * @return LoggerRoot
+ * @static
+ */
+ public function getRootLogger() {
+ return LoggerManager::getRootLogger();
+ }
+
+ /**
+ * Log a message object with the INFO Level.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ public function info($message, $caller = null) {
+ $infoLevel = LoggerLevel::getLevelInfo();
+ if($this->repository->isDisabled($infoLevel)) {
+ return;
+ }
+ if($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $infoLevel, $message);
+ }
+ }
+
+ /**
+ * Is the appender passed as parameter attached to this category?
+ *
+ * @param LoggerAppender $appender
+ */
+ public function isAttached($appender) {
+ return isset($this->aai[$appender->getName()]);
+ }
+
+ /**
+ * Check whether this category is enabled for the DEBUG Level.
+ * @return boolean
+ */
+ public function isDebugEnabled() {
+ $debugLevel = LoggerLevel::getLevelDebug();
+ if($this->repository->isDisabled($debugLevel)) {
+ return false;
+ }
+ return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel()));
+ }
+
+ /**
+ * Check whether this category is enabled for a given Level passed as parameter.
+ *
+ * @param LoggerLevel level
+ * @return boolean
+ */
+ public function isEnabledFor($level) {
+ if($this->repository->isDisabled($level)) {
+ return false;
+ }
+ return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel()));
+ }
+
+ /**
+ * Check whether this category is enabled for the info Level.
+ * @return boolean
+ * @see LoggerLevel
+ */
+ public function isInfoEnabled() {
+ $infoLevel = LoggerLevel::getLevelInfo();
+ if($this->repository->isDisabled($infoLevel)) {
+ return false;
+ }
+ return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel()));
+ }
+
+ /**
+ * Log a localized and parameterized message.
+ */
+ public function l7dlog($priority, $key, $params, $t) {
+ return;
+ }
+
+ /**
+ * This generic form is intended to be used by wrappers.
+ *
+ * @param LoggerLevel $priority a valid level
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ public function log($priority, $message, $caller = null) {
+ if($this->repository->isDisabled($priority)) {
+ return;
+ }
+ if($priority->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $priority, $message);
+ }
+ }
+
+ /**
+ * Remove all previously added appenders from this Category instance.
+ */
+ public function removeAllAppenders() {
+ $appenderNames = array_keys($this->aai);
+ $enumAppenders = sizeof($appenderNames);
+ for($i = 0; $i < $enumAppenders; $i++) {
+ $this->removeAppender($appenderNames[$i]);
+ }
+ }
+
+ /**
+ * Remove the appender passed as parameter form the list of appenders.
+ *
+ * @param mixed $appender can be an appender name or a {@link LoggerAppender} object
+ */
+ public function removeAppender($appender) {
+ if($appender instanceof LoggerAppender) {
+ $appender->close();
+ unset($this->aai[$appender->getName()]);
+ } else if (is_string($appender) and isset($this->aai[$appender])) {
+ $this->aai[$appender]->close();
+ unset($this->aai[$appender]);
+ }
+ }
+
+ /**
+ * Set the additivity flag for this Category instance.
+ *
+ * @param boolean $additive
+ */
+ public function setAdditivity($additive) {
+ $this->additive = (bool)$additive;
+ }
+
+ /**
+ * @deprecated Please use {@link setLevel()} instead.
+ * @see setLevel()
+ */
+ public function setPriority($priority) {
+ $this->setLevel($priority);
+ }
+
+ /**
+ * Only the Hierarchy class can set the hierarchy of a
+ * category.
+ *
+ * @param LoggerHierarchy $repository
+ */
+ public function setHierarchy($repository) {
+ $this->repository = $repository;
+ }
+
+ /**
+ * Set the level of this Category.
+ *
+ * @param LoggerLevel $level a level string or a level constant
+ */
+ public function setLevel($level) {
+ $this->level = $level;
+ }
+
+ public function setParent($logger) {
+ if($logger instanceof Logger) {
+ $this->parent = $logger;
+ }
+ }
+
+ /**
+ * Set the resource bundle to be used with localized logging methods
+ */
+ public function setResourceBundle($bundle) {
+ return;
+ }
+
+ /**
+ * @deprecated use {@link LoggerManager::shutdown()} instead.
+ * @see LoggerManager::shutdown()
+ */
+ public function shutdown() {
+ LoggerManager::shutdown();
+ }
+
+ /**
+ * Log a message with the WARN level.
+ *
+ * @param mixed $message message
+ * @param mixed $caller caller object or caller string id
+ */
+ public function warn($message, $caller = null) {
+ $warnLevel = LoggerLevel::getLevelWarn();
+ if($this->repository->isDisabled($warnLevel)) {
+ return;
+ }
+ if($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) {
+ $this->forcedLog($this->fqcn, $caller, $warnLevel, $message);
+ }
+ }
}
Modified: incubator/log4php/trunk/src/main/php/LoggerAppender.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerAppender.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerAppender.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerAppender.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerAppenderSkeleton.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerAppenderSkeleton.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerAppenderSkeleton.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerAppenderSkeleton.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerBasicConfigurator.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerBasicConfigurator.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerBasicConfigurator.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerBasicConfigurator.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerDefaultCategoryFactory.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerDefaultCategoryFactory.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerDefaultCategoryFactory.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerDefaultCategoryFactory.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerHierarchy.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerHierarchy.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerHierarchy.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerHierarchy.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerLayout.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerLayout.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerLayout.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerLayout.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerLevel.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerLevel.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerLevel.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerLevel.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerLog.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerLog.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerLog.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerLog.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerMDC.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerMDC.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerMDC.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerMDC.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerManager.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerManager.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerManager.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerManager.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerNDC.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerNDC.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerNDC.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerNDC.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/LoggerPropertyConfigurator.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerPropertyConfigurator.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerPropertyConfigurator.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerPropertyConfigurator.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -19,22 +19,22 @@
* @package log4php
*/
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX', "log4php.category.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX', "log4php.logger.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX', "log4php.factory");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX', "log4php.additivity.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX', "log4php.category.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX', "log4php.logger.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_FACTORY_PREFIX', "log4php.factory");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ADDITIVITY_PREFIX', "log4php.additivity.");
define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_CATEGORY_PREFIX', "log4php.rootCategory");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX', "log4php.rootLogger");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX', "log4php.appender.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX', "log4php.renderer.");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX', "log4php.threshold");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_ROOT_LOGGER_PREFIX', "log4php.rootLogger");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX', "log4php.appender.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX', "log4php.renderer.");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_THRESHOLD_PREFIX', "log4php.threshold");
/**
* Key for specifying the {@link LoggerFactory}.
*/
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY', "log4php.loggerFactory");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY', "log4php.debug");
-define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME', "root");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_FACTORY_KEY', "log4php.loggerFactory");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_DEBUG_KEY', "log4php.debug");
+define('LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_INTERNAL_ROOT_NAME', "root");
Modified: incubator/log4php/trunk/src/main/php/LoggerRoot.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerRoot.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerRoot.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerRoot.php Fri May 1 07:58:54 2009
@@ -1,11 +1,11 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
Modified: incubator/log4php/trunk/src/main/php/varia/LoggerDenyAllFilter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/varia/LoggerDenyAllFilter.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/varia/LoggerDenyAllFilter.php (original)
+++ incubator/log4php/trunk/src/main/php/varia/LoggerDenyAllFilter.php Fri May 1 07:58:54 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -35,15 +35,14 @@
*/
class LoggerDenyAllFilter extends LoggerFilter {
- /**
- * Always returns the integer constant {@link LoggerFilter::DENY}
- * regardless of the {@link LoggerLoggingEvent} parameter.
- *
- * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter.
- * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY}
- */
- function decide($event)
- {
- return LoggerFilter::DENY;
- }
+ /**
+ * Always returns the integer constant {@link LoggerFilter::DENY}
+ * regardless of the {@link LoggerLoggingEvent} parameter.
+ *
+ * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter.
+ * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY}
+ */
+ public function decide($event) {
+ return LoggerFilter::DENY;
+ }
}
Modified: incubator/log4php/trunk/src/main/php/varia/LoggerLevelMatchFilter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/varia/LoggerLevelMatchFilter.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/varia/LoggerLevelMatchFilter.php (original)
+++ incubator/log4php/trunk/src/main/php/varia/LoggerLevelMatchFilter.php Fri May 1 07:58:54 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -39,72 +39,66 @@
*/
class LoggerLevelMatchFilter extends LoggerFilter {
- /**
- * @var boolean
- */
- var $acceptOnMatch = true;
+ /**
+ * @var boolean
+ */
+ var $acceptOnMatch = true;
- /**
- * @var LoggerLevel
- */
- var $levelToMatch;
+ /**
+ * @var LoggerLevel
+ */
+ var $levelToMatch;
- /**
- * @return boolean
- */
- function getAcceptOnMatch()
- {
- return $this->acceptOnMatch;
- }
-
- /**
- * @param boolean $acceptOnMatch
- */
- function setAcceptOnMatch($acceptOnMatch)
- {
- $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true);
- }
-
- /**
- * @return LoggerLevel
- */
- function getLevelToMatch()
- {
- return $this->levelToMatch;
- }
-
- /**
- * @param string $l the level to match
- */
- function setLevelToMatch($l)
- {
- $this->levelToMatch = LoggerOptionConverter::toLevel($l, null);
- }
+ /**
+ * @return boolean
+ */
+ function getAcceptOnMatch() {
+ return $this->acceptOnMatch;
+ }
+
+ /**
+ * @param boolean $acceptOnMatch
+ */
+ function setAcceptOnMatch($acceptOnMatch) {
+ $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true);
+ }
+
+ /**
+ * @return LoggerLevel
+ */
+ function getLevelToMatch() {
+ return $this->levelToMatch;
+ }
+
+ /**
+ * @param string $l the level to match
+ */
+ function setLevelToMatch($l) {
+ $this->levelToMatch = LoggerOptionConverter::toLevel($l, null);
+ }
- /**
- * Return the decision of this filter.
- *
- * Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
- * option is not set or if there is not match. Otherwise, if there is a
- * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
- * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
- * returned decision is {@link LoggerFilter::DENY} if the
- * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
- *
- * @param LoggerLoggingEvent $event
- * @return integer
- */
- function decide($event)
- {
- if($this->levelToMatch === null)
- return LoggerFilter::NEUTRAL;
-
- if ($this->levelToMatch->equals($event->getLevel())) {
- return $this->getAcceptOnMatch() ?
- LoggerFilter::ACCEPT :
- LoggerFilter::DENY;
- } else {
- return LoggerFilter::NEUTRAL;
- }
- }
+ /**
+ * Return the decision of this filter.
+ *
+ * Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
+ * option is not set or if there is not match. Otherwise, if there is a
+ * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
+ * returned decision is {@link LoggerFilter::DENY} if the
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
+ *
+ * @param LoggerLoggingEvent $event
+ * @return integer
+ */
+ function decide($event) {
+ if($this->levelToMatch === null) {
+ return LoggerFilter::NEUTRAL;
+ }
+
+ if($this->levelToMatch->equals($event->getLevel())) {
+ return $this->getAcceptOnMatch() ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
+ } else {
+ return LoggerFilter::NEUTRAL;
+ }
+ }
}
Modified: incubator/log4php/trunk/src/main/php/varia/LoggerLevelRangeFilter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/varia/LoggerLevelRangeFilter.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/varia/LoggerLevelRangeFilter.php (original)
+++ incubator/log4php/trunk/src/main/php/varia/LoggerLevelRangeFilter.php Fri May 1 07:58:54 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -23,19 +23,19 @@
/**
* This is a very simple filter based on level matching, which can be
* used to reject messages with priorities outside a certain range.
- *
+ *
* <p>The filter admits three options <b><var>LevelMin</var></b>, <b><var>LevelMax</var></b>
* and <b><var>AcceptOnMatch</var></b>.</p>
*
* <p>If the level of the {@link LoggerLoggingEvent} is not between Min and Max
* (inclusive), then {@link LoggerFilter::DENY} is returned.</p>
- *
+ *
* <p>If the Logging event level is within the specified range, then if
* <b><var>AcceptOnMatch</var></b> is <i>true</i>,
* {@link LoggerFilter::ACCEPT} is returned, and if
* <b><var>AcceptOnMatch</var></b> is <i>false</i>,
* {@link LoggerFilter::NEUTRAL} is returned.</p>
- *
+ *
* <p>If <b><var>LevelMin</var></b> is not defined, then there is no
* minimum acceptable level (i.e. a level is never rejected for
* being too "low"/unimportant). If <b><var>LevelMax</var></b> is not
@@ -56,104 +56,97 @@
* @since 0.6
*/
class LoggerLevelRangeFilter extends LoggerFilter {
+
+ /**
+ * @var boolean
+ */
+ var $acceptOnMatch = true;
+
+ /**
+ * @var LoggerLevel
+ */
+ var $levelMin;
- /**
- * @var boolean
- */
- var $acceptOnMatch = true;
-
- /**
- * @var LoggerLevel
- */
- var $levelMin;
-
- /**
- * @var LoggerLevel
- */
- var $levelMax;
-
- /**
- * @return boolean
- */
- function getAcceptOnMatch()
- {
- return $this->acceptOnMatch;
- }
-
- /**
- * @param boolean $acceptOnMatch
- */
- function setAcceptOnMatch($acceptOnMatch)
- {
- $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true);
- }
-
- /**
- * @return LoggerLevel
- */
- function getLevelMin()
- {
- return $this->levelMin;
- }
-
- /**
- * @param string $l the level min to match
- */
- function setLevelMin($l)
- {
- $this->levelMin = LoggerOptionConverter::toLevel($l, null);
- }
-
- /**
- * @return LoggerLevel
- */
- function getLevelMax()
- {
- return $this->levelMax;
- }
-
- /**
- * @param string $l the level max to match
- */
- function setLevelMax($l)
- {
- $this->levelMax = LoggerOptionConverter::toLevel($l, null);
- }
-
- /**
- * Return the decision of this filter.
- *
- * @param LoggerLoggingEvent $event
- * @return integer
- */
- function decide($event)
- {
- $level = $event->getLevel();
-
- if($this->levelMin !== null) {
- if ($level->isGreaterOrEqual($this->levelMin) == false) {
- // level of event is less than minimum
- return LoggerFilter::DENY;
- }
- }
-
- if($this->levelMax !== null) {
- if ($level->toInt() > $this->levelMax->toInt()) {
- // level of event is greater than maximum
- // Alas, there is no Level.isGreater method. and using
- // a combo of isGreaterOrEqual && !Equal seems worse than
- // checking the int values of the level objects..
- return LoggerFilter::DENY;
- }
- }
-
- if ($this->getAcceptOnMatch()) {
- // this filter set up to bypass later filters and always return
- // accept if level in range
- return LoggerFilter::ACCEPT;
- } else {
- // event is ok for this filter; allow later filters to have a look..
- return LoggerFilter::NEUTRAL;
- }
- }
+ /**
+ * @var LoggerLevel
+ */
+ var $levelMax;
+
+ /**
+ * @return boolean
+ */
+ function getAcceptOnMatch() {
+ return $this->acceptOnMatch;
+ }
+
+ /**
+ * @param boolean $acceptOnMatch
+ */
+ function setAcceptOnMatch($acceptOnMatch) {
+ $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true);
+ }
+
+ /**
+ * @return LoggerLevel
+ */
+ function getLevelMin() {
+ return $this->levelMin;
+ }
+
+ /**
+ * @param string $l the level min to match
+ */
+ function setLevelMin($l) {
+ $this->levelMin = LoggerOptionConverter::toLevel($l, null);
+ }
+
+ /**
+ * @return LoggerLevel
+ */
+ function getLevelMax() {
+ return $this->levelMax;
+ }
+
+ /**
+ * @param string $l the level max to match
+ */
+ function setLevelMax($l) {
+ $this->levelMax = LoggerOptionConverter::toLevel($l, null);
+ }
+
+ /**
+ * Return the decision of this filter.
+ *
+ * @param LoggerLoggingEvent $event
+ * @return integer
+ */
+ function decide($event) {
+ $level = $event->getLevel();
+
+ if($this->levelMin !== null) {
+ if($level->isGreaterOrEqual($this->levelMin) == false) {
+ // level of event is less than minimum
+ return LoggerFilter::DENY;
+ }
+ }
+
+ if($this->levelMax !== null) {
+ if($level->toInt() > $this->levelMax->toInt()) {
+ // level of event is greater than maximum
+ // Alas, there is no Level.isGreater method. and using
+ // a combo of isGreaterOrEqual && !Equal seems worse than
+ // checking the int values of the level objects..
+ return LoggerFilter::DENY;
+ }
+ }
+
+ if($this->getAcceptOnMatch()) {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return LoggerFilter::ACCEPT;
+ } else {
+ // event is ok for this filter; allow later filters to have a look..
+ return LoggerFilter::NEUTRAL;
+ }
+ }
}
Modified: incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php?rev=770568&r1=770567&r2=770568&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php (original)
+++ incubator/log4php/trunk/src/main/php/varia/LoggerStringMatchFilter.php Fri May 1 07:58:54 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -38,63 +38,58 @@
* @since 0.3
*/
class LoggerStringMatchFilter extends LoggerFilter {
-
- /**
- * @var boolean
- */
- var $acceptOnMatch = true;
- /**
- * @var string
- */
- var $stringToMatch = null;
+ /**
+ * @var boolean
+ */
+ var $acceptOnMatch = true;
+
+ /**
+ * @var string
+ */
+ var $stringToMatch = null;
- /**
- * @return boolean
- */
- function getAcceptOnMatch()
- {
- return $this->acceptOnMatch;
- }
-
- /**
- * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
- */
- function setAcceptOnMatch($acceptOnMatch)
- {
- $this->acceptOnMatch = is_bool($acceptOnMatch) ?
- $acceptOnMatch :
- (bool)(strtolower($acceptOnMatch) == 'true');
- }
-
- /**
- * @return string
- */
- function getStringToMatch()
- {
- return $this->stringToMatch;
- }
-
- /**
- * @param string $s the string to match
- */
- function setStringToMatch($s)
- {
- $this->stringToMatch = $s;
- }
+ /**
+ * @return boolean
+ */
+ function getAcceptOnMatch() {
+ return $this->acceptOnMatch;
+ }
+
+ /**
+ * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
+ */
+ function setAcceptOnMatch($acceptOnMatch) {
+ $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true');
+ }
+
+ /**
+ * @return string
+ */
+ function getStringToMatch() {
+ return $this->stringToMatch;
+ }
+
+ /**
+ * @param string $s the string to match
+ */
+ function setStringToMatch($s) {
+ $this->stringToMatch = $s;
+ }
- /**
- * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
- */
- function decide($event)
- {
- $msg = $event->getRenderedMessage();
-
- if($msg === null or $this->stringToMatch === null)
- return LoggerFilter::NEUTRAL;
- if( strpos($msg, $this->stringToMatch) !== false ) {
- return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY ;
- }
- return LoggerFilter::NEUTRAL;
- }
+ /**
+ * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
+ */
+ function decide($event) {
+ $msg = $event->getRenderedMessage();
+
+ if($msg === null or $this->stringToMatch === null) {
+ return LoggerFilter::NEUTRAL;
+ }
+
+ if(strpos($msg, $this->stringToMatch) !== false ) {
+ return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY ;
+ }
+ return LoggerFilter::NEUTRAL;
+ }
}