Zend_Log_Exception example


    public function __construct($streamOrUrl$mode = null)
    {
        // Setting the default         if (null === $mode) {
            $mode = 'a';
        }

        if (is_resource($streamOrUrl)) {
            if (get_resource_type($streamOrUrl) != 'stream') {
                throw new Zend_Log_Exception('Resource is not a stream');
            }

            if ($mode != 'a') {
                throw new Zend_Log_Exception('Mode cannot be changed on existing streams');
            }

            $this->_stream = $streamOrUrl;
        } else {
            if (is_array($streamOrUrl) && isset($streamOrUrl['stream'])) {
                $streamOrUrl = $streamOrUrl['stream'];
            }

            

    }

    /** * Formatting is not possible on this writer * * @return void * @throws Zend_Log_Exception */
    public function setFormatter(Zend_Log_Formatter_Interface $formatter)
    {
        throw new Zend_Log_Exception(get_class($this) . ' does not support formatting');
    }

    /** * Remove reference to database adapter * * @return void */
    public function shutdown()
    {
        $this->_db = null;
    }

    

    public function __construct($priority$operator = null)
    {
        if (is_int($priority)) {
            throw new Zend_Log_Exception('Priority must be an integer');
        }

        $this->_priority = $priority;
        $this->_operator = $operator === null ? '<=' : $operator;
    }

    /** * Create a new instance of Zend_Log_Filter_Priority * * @param array|Zend_Config $config * @return Zend_Log_Filter_Priority */

    public function addFilter($filter)
    {
        if (is_int($filter)) {
            $filter = new Zend_Log_Filter_Priority($filter);
        }

        if (!$filter instanceof Zend_Log_Filter_Interface) {
            /** @see Zend_Log_Exception */
            throw new Zend_Log_Exception('Invalid filter provided');
        }

        $this->_filters[] = $filter;
        return $this;
    }

    /** * Log a message to this writer. * * @param array $event log data event * @return void */

    static protected function _parseConfig($config)
    {
        if ($config instanceof Zend_Config) {
            $config = $config->toArray();
        }

        if (!is_array($config)) {
            throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config');
        }

        return $config;
    }
}

    static public function factory($config = array())
    {
        if ($config instanceof Zend_Config) {
            $config = $config->toArray();
        }

        if (!is_array($config) || empty($config)) {
            /** @see Zend_Log_Exception */
            throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config');
        }

        $log = new self;

        if (array_key_exists('timestampFormat', $config)) {
            if (null != $config['timestampFormat'] && '' != $config['timestampFormat']) {
                $log->setTimestampFormat($config['timestampFormat']);
            }
            unset($config['timestampFormat']);
        }

        

        $mailClass = 'Zend_Mail';
        if (isset($config['mail'])) {
            $mailClass = $config['mail'];
        }

        if (!array_key_exists('charset', $config)) {
            $config['charset'] = null;
        }
        $mail = new $mailClass($config['charset']);
        if (!$mail instanceof Zend_Mail) {
            throw new Zend_Log_Exception($mail . 'must extend Zend_Mail');
        }

        if (isset($config['subject'])) {
            $mail->setSubject($config['subject']);
        }

        $headerAddresses = array_intersect_key($config, self::$_methodMapHeaders);
        if (count($headerAddresses)) {
            foreach ($headerAddresses as $header => $address) {
                $method = self::$_methodMapHeaders[$header];
                if (is_array($address) && isset($address['name'])
                    
/** * Filter out any log messages not matching $regexp. * * @param string $regexp Regular expression to test the log message * @return void * @throws Zend_Log_Exception */
    public function __construct($regexp)
    {
        if (@preg_match($regexp, '') === false) {
            throw new Zend_Log_Exception("Invalid regular expression '$regexp'");
        }
        $this->_regexp = $regexp;
    }

    /** * Create a new instance of Zend_Log_Filter_Message * * @param array|Zend_Config $config * @return Zend_Log_Filter_Message */
    static public function factory($config)
    {
public function setFacility($facility)
    {
        if ($this->_facility === $facility) {
            return $this;
        }

        if (!count($this->_validFacilities)) {
            $this->_initializeValidFacilities();
        }

        if (!in_array($facility$this->_validFacilities)) {
            throw new Zend_Log_Exception('Invalid log facility provided; please see http://php.net/openlog for a list of valid facility values');
        }

        if ('WIN' == strtoupper(substr(PHP_OS, 0, 3))
            && ($facility !== LOG_USER)
        ) {
            throw new Zend_Log_Exception('Only LOG_USER is a valid log facility on Windows');
        }

        $this->_facility = $facility;
        $this->_initializeSyslog();
        return $this;
    }

    public function __construct($format = null)
    {
        if ($format === null) {
            $format = self::DEFAULT_FORMAT . PHP_EOL;
        }

        if (!is_string($format)) {
            throw new Zend_Log_Exception('Format must be a string');
        }

        $this->_format = $format;
    }

    /** * Factory for Zend_Log_Formatter_Simple classe * * @param array|Zend_Config $options * @return Zend_Log_Formatter_Simple */
    
Home | Imprint | This part of the site doesn't use cookies.