Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2682915
D25388.1734675429.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
D25388.1734675429.diff
View Options
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 $error_listener) {
+ call_user_func($error_listener, $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
diff --git a/src/filesystem/PhutilErrorLog.php b/src/filesystem/PhutilErrorLog.php
--- a/src/filesystem/PhutilErrorLog.php
+++ b/src/filesystem/PhutilErrorLog.php
@@ -83,7 +83,7 @@
}
public function onError($event, $value, array $metadata) {
- // If we've set "error_log" to a real file, so messages won't be output to
+ // If we've set "error_log" to a real file, messages won't be output to
// stderr by default. Copy them to stderr.
if ($this->logPath === null) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 06:17 (19 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015161
Default Alt Text
D25388.1734675429.diff (3 KB)
Attached To
Mode
D25388: PhutilErrorHandler: support multiple error listeners
Attached
Detach File
Event Timeline
Log In to Comment