mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
2cca0b0a7b
MINOR Moved SSErrorLogTest to SSLogTest MINOR Documentation updates for SSLog and other bits and pieces git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84828 467b73ca-7a2a-4603-9d3b-597d59a354a9
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Formats SS error entries in an error file log.
|
|
* Format: [d-M-Y h:i:s] <type> at <file> line <line>: <errormessage> <url>
|
|
* @package sapphire
|
|
* @subpackage dev
|
|
*/
|
|
|
|
require_once 'Zend/Log/Formatter/Interface.php';
|
|
|
|
class SSLogErrorFileFormatter implements Zend_Log_Formatter_Interface {
|
|
|
|
public function format($event) {
|
|
$errno = $event['message']['errno'];
|
|
$errstr = $event['message']['errstr'];
|
|
$errfile = $event['message']['errfile'];
|
|
$errline = $event['message']['errline'];
|
|
$errcontext = $event['message']['errcontext'];
|
|
|
|
switch($event['priorityName']) {
|
|
case 'ERR':
|
|
$errtype = 'Error';
|
|
break;
|
|
case 'WARN':
|
|
$errtype = 'Warning';
|
|
break;
|
|
case 'NOTICE':
|
|
$errtype = 'Notice';
|
|
break;
|
|
}
|
|
|
|
$urlSuffix = '';
|
|
$relfile = Director::makeRelative($errfile);
|
|
if($relfile[0] == '/') $relfile = substr($relfile, 1);
|
|
if(isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] && isset($_SERVER['REQUEST_URI'])) {
|
|
$urlSuffix = " (http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI])";
|
|
}
|
|
|
|
return '[' . date('d-M-Y h:i:s') . "] $errtype at $relfile line $errline: $errstr$urlSuffix\n";
|
|
}
|
|
|
|
} |