File: php_error_handler.php

package info (click to toggle)
php-log 1.10.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 404 kB
  • ctags: 592
  • sloc: php: 1,822; xml: 237; sql: 8; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (8)
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
<?php

require_once 'Log.php';

function errorHandler($code, $message, $file, $line)
{
    global $logger;

    /* Map the PHP error to a Log priority. */
    switch ($code) {
    case E_WARNING:
    case E_USER_WARNING:
        $priority = PEAR_LOG_WARNING;
        break;
    case E_NOTICE:
    case E_USER_NOTICE:
        $priority = PEAR_LOG_NOTICE;
        break;
    case E_ERROR:
    case E_USER_ERROR:
        $priority = PEAR_LOG_ERR;
        break;
    default:
        $priotity = PEAR_LOG_INFO;
    }

    $logger->log($message . ' in ' . $file . ' at line ' . $line,
                 $priority);
}

$logger = &Log::singleton('console', '', 'ident');

set_error_handler('errorHandler');
trigger_error('This is an information log message.', E_USER_NOTICE);