diff --git a/library/log4php/LoggerAppenderPool.php b/library/log4php/LoggerAppenderPool.php new file mode 100644 --- /dev/null +++ b/library/log4php/LoggerAppenderPool.php @@ -0,0 +1,98 @@ +getName(); + + if (empty($name)) { + trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING); + return; + } + + if (isset(self::$appenders[$name])) { + trigger_error("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING); + } + + self::$appenders[$name] = $appender; + } + + /** + * Retrieves an appender from the pool by name. + * @param string $name Name of the appender to retrieve. + * @return LoggerAppender The named appender or NULL if no such appender + * exists in the pool. + */ + public static function get($name) { + return isset(self::$appenders[$name]) ? self::$appenders[$name] : null; + } + + /** + * Removes an appender from the pool by name. + * @param string $name Name of the appender to remove. + */ + public static function delete($name) { + unset(self::$appenders[$name]); + } + + /** + * Returns all appenders from the pool. + * @return array Array of LoggerAppender objects. + */ + public static function getAppenders() { + return self::$appenders; + } + + /** + * Checks whether an appender exists in the pool. + * @param string $name Name of the appender to look for. + * @return boolean TRUE if the appender with the given name exists. + */ + public static function exists($name) { + return isset(self::$appenders[$name]); + } + + /** + * Clears all appenders from the pool. + */ + public static function clear() { + self::$appenders = array(); + } +} \ No newline at end of file