Page MenuHomePhorge

D25388.1737300701.diff
No OneTemporary

D25388.1737300701.diff

diff --git a/src/error/PhutilErrorHandler.php b/src/error/PhutilErrorHandler.php
--- a/src/error/PhutilErrorHandler.php
+++ b/src/error/PhutilErrorHandler.php
@@ -6,7 +6,7 @@
*
* This class takes over the PHP error and exception handlers when you call
* ##PhutilErrorHandler::initialize()## and forwards all debugging information
- * to a listener you install with ##PhutilErrorHandler::setErrorListener()##.
+ * to a listener you install with ##PhutilErrorHandler::addErrorListener()##.
*
* To use PhutilErrorHandler, which will enhance the messages printed to the
* PHP error log, just initialize it:
@@ -16,7 +16,7 @@
* To additionally install a custom listener which can print error information
* to some other file or console, register a listener:
*
- * PhutilErrorHandler::setErrorListener($some_callback);
+ * PhutilErrorHandler::addErrorListener($some_callback);
*
* For information on writing an error listener, see
* @{function:phutil_error_listener_example}. Providing a listener is optional,
@@ -31,7 +31,7 @@
*/
final class PhutilErrorHandler extends Phobject {
- private static $errorListener = null;
+ private static $errorListeners = array();
private static $initialized = false;
private static $traps = array();
@@ -68,8 +68,15 @@
* @return void
* @task config
*/
+ public static function addErrorListener($listener) {
+ self::$errorListeners[] = $listener;
+ }
+
+ /**
+ * Deprecated - use `addErrorListener`.
+ */
public static function setErrorListener($listener) {
- self::$errorListener = $listener;
+ self::addErrorListener($listener);
}
@@ -438,7 +445,7 @@
break;
}
- if (self::$errorListener) {
+ if (self::$errorListeners) {
static $handling_error;
if ($handling_error) {
error_log(
@@ -447,7 +454,9 @@
return;
}
$handling_error = true;
- call_user_func(self::$errorListener, $event, $value, $metadata);
+ foreach (self::$errorListeners as $errorListener) {
+ call_user_func($errorListener, $event, $value, $metadata);
+ }
$handling_error = false;
}
}
diff --git a/src/error/phlog.php b/src/error/phlog.php
--- a/src/error/phlog.php
+++ b/src/error/phlog.php
@@ -41,7 +41,7 @@
/**
* Example @{class:PhutilErrorHandler} error listener callback. When you call
- * `PhutilErrorHandler::setErrorListener()`, you must pass a callback function
+ * `PhutilErrorHandler::addErrorListener()`, you must pass a callback function
* with the same signature as this one.
*
* NOTE: @{class:PhutilErrorHandler} handles writing messages to the error

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 19, 15:31 (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1133884
Default Alt Text
D25388.1737300701.diff (2 KB)

Event Timeline