Zend_log: Conseil Zend_Log_Writer_Firebug
Bonjour à tous,
Je viens vers vous pour des conseils, des infos ou des tuto. Je veux mettre en place des log.
J'ai commencé par mettre en place
application.ini:
Code:
1 2 3 4
| resources.log.firebug.writerName = "Firebug"
resources.log.firebug.writerParams.stream = APPLICATION_PATH "/../logs/firebug.log"
resources.log.firebug.filterName = "Priority"
resources.log.firebug.filterParams.priority = 7 |
Bootstrap.php:
Code:
1 2 3 4 5 6 7
| protected function _initLogger() {
$this->bootstrap ( 'log' );
$logger = $this->getResource( 'log' );
Zend_Registry::set ( 'Zend_Log', $logger );
} |
ErrorController.php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| public function errorAction() {
$errors = $this->_getParam ( 'error_handler' );
if (! $errors || ! $errors instanceof ArrayObject) {
$this->view->message = 'You have reached the error page';
return;
}
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE :
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
// 404 error -- controller or action not found
$this->getResponse ()->setHttpResponseCode(404);
$priority = Zend_Log::NOTICE;
$this->view->message = 'Page not found';
break;
default :
// application error
$this->getResponse ()->setHttpResponseCode(500);
$priority = Zend_Log::CRIT;
$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
if ($log = $this->getLog ()) {
$log->log ( $this->view->message, $priority, $errors->exception );
$log->log ( 'Request Parameters', $priority, $errors->request->getParams() );
}
// conditionally display exceptions
if ($this->getInvokeArg ( 'displayExceptions' ) == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
public function getLog() {
$bootstrap = $this->getInvokeArg ( 'bootstrap' );
if (! $bootstrap->hasResource ( 'Log' )) {
return false;
}
$log = $bootstrap->getResource ( 'Log' );
return $log;
} |
Pouvez-vous m'aider ou me conseiller pour avance ?
Merci d'avance