/** * Attempts to return a reference to a concrete Log instance of $type, only * creating a new instance if no log instance with the same parameters * currently exists. * * You should use this if there are multiple places you might create a * logger, you don't want to create multiple loggers, and you don't want to * check for the existance of one each time. The singleton pattern does all * the checking work for you. * * <b>You MUST call this method with the $var = &epLib_Log::singleton() syntax. * Without the ampersand (&) in front of the method name, you will not get * a reference, you will get a copy.</b> * * @param string $type The type of concrete Log subclass to return. * Attempt to dynamically include the code for * this subclass. Currently, valid values are * 'console', 'syslog', 'sql', 'file', and 'mcal'. * * @param string $name The name of the actually log file, table, or * other specific store to use. Defaults to an * empty string, with which the subclass will * attempt to do something intelligent. * * @param string $ident The identity reported to the log system. * * @param array $conf A hash containing any additional configuration * information that a subclass might need. * * @param int $maxLevel Minimum priority level at which to log. * * @return object Log The newly created concrete Log instance, or an * false on an error. * @access public */ function &singleton($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG) { static $instances; if (!isset($instances)) { $instances = array(); } $signature = serialize(array($type, $name, $ident, $conf, $maxLevel)); if (!isset($instances[$signature])) { $instances[$signature] =& epLib_Log::factory($type, $name, $ident, $conf, $maxLevel); } return $instances[$signature]; }