PEAR_ErrorStack improvements

Introduction

PEAR_ErrorStack with its great features, is still young and could be improved again. It has built-in support for PEAR::Log, to log errors as they occur. It's a very cool feature, but sometimes developpers have already a own logging system, and they can't plug-in PEAR_ErrorStack without coding again the Log interface.

With this proposal, we could used PEAR_ErrorStack with all Loggers: PEAR::Log or a private system.

Source Codes Updates:

2004-12-21: feature added to allows to log an error and halt a script easily. The new bundle available to download is PEAR_ErrorStack-1.4.0dev3.tgz

2004-11-29: fixed some minor errors with myPHPLogger.php. The new bundle available to download is PEAR_ErrorStack-1.4.0dev2.tgz

Changes on PEAR_ErrorStack

NOTE: lines number striked are related to PEAR_ErrorStack-1.4.0dev2.tgz (previous proposal)

Have a look on source code [1]; functions modified are :

The setDefaultLogger and setLogger methods allows now to defines any valid callback, AND NO MORE only a PEAR::Log object.
A valid callback is:

The _log method, allows now to log error message with PEAR::Log 1.8.7 (1.9.0, not yet released, because requires my hack: see cvs http://cvs.php.net/co.php/pear/Log/Log.php?r=1.46).

Example of private error logging system with only PHP functions

Have a look on source code [2]. The class is defined on lines 11 to 110. A new instance is created on line 113 with all default options, and on lines 116 to 122, we've created a custom configuration. Logging errors (display, and file ) occurs only if php.ini directives are set to '1' (see lines 58, 59).

The new PEAR_ErrorStack unit test

Have a look on source code [3]. This example will use the new version of PEAR_ErrorStack with: