2009-08-19 23:55:03 +02:00
|
|
|
<?php
|
2010-04-23 02:11:41 +02:00
|
|
|
require_once 'Zend/Log/Formatter/Interface.php';
|
|
|
|
|
2009-08-19 23:55:03 +02:00
|
|
|
/**
|
|
|
|
* Formats SS error entries in an error file log.
|
|
|
|
* Format: [d-M-Y h:i:s] <type> at <file> line <line>: <errormessage> <url>
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2009-08-19 23:55:03 +02:00
|
|
|
* @subpackage dev
|
|
|
|
*/
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
MINOR: Replaced usage of renamed classes with the new namespaced name.
From: Andrew Short <andrewjshort@gmail.com>
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90075 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-10-26 04:06:31 +01:00
|
|
|
class SS_LogErrorFileFormatter implements Zend_Log_Formatter_Interface {
|
2009-08-19 23:55:03 +02:00
|
|
|
|
|
|
|
public function format($event) {
|
|
|
|
$errno = $event['message']['errno'];
|
|
|
|
$errstr = $event['message']['errstr'];
|
|
|
|
$errfile = $event['message']['errfile'];
|
|
|
|
$errline = $event['message']['errline'];
|
|
|
|
$errcontext = $event['message']['errcontext'];
|
2014-02-24 03:38:53 +01:00
|
|
|
|
2009-08-19 23:55:03 +02:00
|
|
|
switch($event['priorityName']) {
|
|
|
|
case 'ERR':
|
|
|
|
$errtype = 'Error';
|
|
|
|
break;
|
|
|
|
case 'WARN':
|
|
|
|
$errtype = 'Warning';
|
|
|
|
break;
|
|
|
|
case 'NOTICE':
|
|
|
|
$errtype = 'Notice';
|
|
|
|
break;
|
2014-02-24 03:38:53 +01:00
|
|
|
default:
|
|
|
|
$errtype = $event['priorityName'];
|
2009-08-19 23:55:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$urlSuffix = '';
|
|
|
|
$relfile = Director::makeRelative($errfile);
|
2012-12-06 00:42:24 +01:00
|
|
|
if(strlen($relfile) && $relfile[0] == '/') $relfile = substr($relfile, 1);
|
2009-08-19 23:55:03 +02:00
|
|
|
if(isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] && isset($_SERVER['REQUEST_URI'])) {
|
|
|
|
$urlSuffix = " (http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI])";
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:17:14 +01:00
|
|
|
return '[' . date('d-M-Y H:i:s') . "] $errtype at $relfile line $errline: $errstr$urlSuffix" . PHP_EOL;
|
2009-08-19 23:55:03 +02:00
|
|
|
}
|
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|