Location: PHPKode > scripts > SVF_Log > svf_log/library/SVF/Controller/Plugin/Log/Php.php
<?php
/**
 * SVF_Controller_Plugin_Log_Php
 * 
 * LICENSE
 *
 * This source file is subject to the BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://svf.webutilities.ch/license/bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to hide@address.com so we can send you a copy immediately.
 * 
 * @package    SVF
 * @category   Controller
 * @subpackage Controller
 * @uses       Zend_Controller_Plugin_Abstract
 * @uses       Zend_Controller_Request_Abstract
 * @uses       SVF_Log
 * @copyright  Copyright (c) 2002-2008 Webutilities CH Inc. (http://www.webutilities.ch)
 * @license    BSD {@link http://svf.webutilities.ch/license/bsd}
 * @author     Silvan von Felten
 * @version    $Id$
 */
require_once 'Zend/Controller/Plugin/Abstract.php';
require_once 'Zend/Controller/Request/Abstract.php';

class SVF_Controller_Plugin_Log_Php extends Zend_Controller_Plugin_Abstract
{
   /** 
    * Instance 
    * 
    * @var Zend_Controller_Request_Abstract 
    */ 
    protected $_request; 

    /**
     * Route Startup handler
     * 
     * @param  Zend_Controller_Request_Abstract $request 
     * @return void
     */
    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        $this->_request = $request;
        $this->initLog();
    }

    /**
     * Initialize php logger
     * 
     * @return SVF_Plugin_Initialize
     */
    public function initLog()
    {
       	require_once 'SVF/Log.php';
    	$log = new SVF_Log;
		// Set evants for this logger
		$log->setEventItems
    	(
    		array
    		(
    			'pid' => getmypid(), 
    			'prog' => APPLICATION_NAME,
    			'version' => APPLICATION_VERSION
    		)	
    	);
    	/**
    	 * Add php logger
   		 * Only act when 
   		 * SVF_Log::EMERG | SVF_Log::ALERT | 
   		 * SVF_Log::CRIT | SVF_Log::ERR | 
   		 * SVF_Log::WARN
   		 */	
   		$log->addPhp(SVF_Log::WARN);
   		// Set an formatter simple for writer instances
		$log->setWriterFormatterSimple
		(
			// Get the php writer instance
			$log->getWriterPhp(),
			// Set the writer with this simple string
			"%timestamp% %prog%-%version% %pid% %priorityName% ".
				"(%priority%): %message%".PHP_EOL.'<br />'
		);

		// Set the logger to the registry
       	Zend_Registry::set('log', $log);
        return $this;
    }
}

Return current item: SVF_Log