/** * Log an exception to the exception log (if enabled). * * This method must not assume the exception is an MWException, * it is also used to handle PHP exceptions or exceptions from other libraries. * * @since 1.22 * @param Exception|Throwable $e */ public static function logException($e) { if (!$e instanceof MWException || $e->isLoggable()) { $logger = LoggerFactory::getInstance('exception'); $logger->error(self::getLogMessage($e), self::getLogContext($e)); $json = self::jsonSerializeException($e, false, FormatJson::ALL_OK); if ($json !== false) { $logger = LoggerFactory::getInstance('exception-json'); $logger->error($json, ['private' => true]); } Hooks::run('LogException', [$e, false]); } }