<?php
/**
* SVF_Controller_Plugin_Log_File
*
* 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_File 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 file logger
*
* @return SVF_Plugin_Initialize
*/
public function initLog()
{
require_once 'SVF/Log.php';
$file = '../application/log/messages_log';
$log = new SVF_Log;
$log->setEventItems
(
array
(
'pid' => getmypid(),
'prog' => APPLICATION_NAME,
'version' => APPLICATION_VERSION
)
);
/**
* Add file logger
* Act ALL
*/
$log->addFile($file);
// Set an formatter simple for writer instances
$log->setWriterFormatterSimple
(
// Get the file writer instance of './log/access_log'
$log->getWriterFile($file),
// Set the writer 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;
}
}