Location: PHPKode > scripts > SVF_Log > svf_log/library/SVF/Controller/Plugin/Log/Hard.php
<?php
/**
 * SVF_Controller_Plugin_Log_Hard
 * 
 * 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://framework.zend.com/license/new-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_Hard 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 logger(s)
     * 
     * @return SVF_Plugin_Initialize
     */
    public function initLog()
    {
       	defined('SVF_LOG_TABLE') or
       		define('SVF_LOG_TABLE', true);
      	require_once 'SVF/Log.php';
       	$accessFile = '../application/log/access_log';
       	$errorFile = '../application/log/error_log';
    	$log = new SVF_Log;
		// Set evants for this logger
		$log->setEventItems
    	(
    		array
    		(
    			'pid' => getmypid(), 
    			'prog' => APPLICATION_NAME,
    			'version' => APPLICATION_VERSION
    		)	
    	);
    	/**
    	 * Add filters to all writers
    	 * $log->filter(Zend_Log::WARN)
    	 */ 	
    	// Add prioritys to the logger
    	$log->addPrioritys(array('TABLE' => 8));
    	// Add firebug logger
  	  	$log->addFirebug();
    	// Get the firebug writer and set the a priority style
 		$log->getWriterFirebug()->setPriorityStyle(8, 'TABLE');
    	/**
    	 * 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);
     	/**
    	 *	Add access file logger
   		 *	Act ALL
   		 */	
	 	$log->addFile($accessFile, SVF_Log::INFO);
      	/**
    	 * Add error file logger
   		 * Only act when 
   		 * SVF_Log::EMERG | SVF_Log::ALERT | 
   		 * SVF_Log::CRIT | SVF_Log::ERR | 
   		 * SVF_Log::WARN
   		 */	
 		$log->addFile($errorFile, SVF_Log::WARN);
  		// Add an formatter simple for php 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 an formatter simple for file writer instances
		$log->setWriterFormatterSimples
		(
			array
			(
				// Get the file writer instance of '$accessFile'
				$log->getWriterFile($accessFile),
				// Get the file writer instance of '$errorFile'
				$log->getWriterFile($errorFile),
			),
			// Set the writers with this simple string
			"%timestamp% %prog%-%version% %pid% %priorityName% ".
				"(%priority%): %message%".PHP_EOL
		);
		// Set the logger to the registry
       	Zend_Registry::set('log', $log);
        return $this;
    }
}

Return current item: SVF_Log