From d5a0e5704f67466c371080aa2ddd46a91a6d0c77 Mon Sep 17 00:00:00 2001 From: Lukas Buchs Date: Wed, 21 Mar 2018 12:18:49 +0100 Subject: [PATCH] new function: logs an exception to the console --- ChromePhp.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ChromePhp.php b/ChromePhp.php index 577b1ce..e6c536c 100755 --- a/ChromePhp.php +++ b/ChromePhp.php @@ -185,6 +185,29 @@ public static function error() return self::_log(self::ERROR, $args); } + /** + * logs an exception to the console + * + * @param Exception|Error $ex + * @return void + */ + public static function exception($ex) + { + if (!($ex instanceof Exception) && !($ex instanceof Error)) { + return self::error($ex); + } + + $type = self::ERROR; + $logger = self::getInstance(); + $logger->_processed = array(); + + $logs = array(); + $logs[] = $ex->getMessage(); + $backtrace_message = $ex->getFile() . ' : ' . $ex->getLine(); + + $logger->_addRow($logs, $backtrace_message, $type); + } + /** * sends a group log *