예제 #1
0
 /**
  * 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]);
     }
 }
예제 #2
0
 /**
  * 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 $e
  */
 public static function logException(Exception $e)
 {
     global $wgLogExceptionBacktrace;
     if (!$e instanceof MWException || $e->isLoggable()) {
         $log = self::getLogMessage($e);
         if ($wgLogExceptionBacktrace) {
             wfDebugLog('exception', $log . "\n" . $e->getTraceAsString());
         } else {
             wfDebugLog('exception', $log);
         }
         $json = self::jsonSerializeException($e, false, FormatJson::ALL_OK);
         if ($json !== false) {
             wfDebugLog('exception-json', $json, 'private');
         }
         Hooks::run('LogException', array($e, false));
     }
 }
예제 #3
0
	/**
	 * 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 errors or errors from other libraries.
	 *
	 * @since 1.22
	 * @param Exception $e
	 */
	public static function logException( Exception $e ) {
		global $wgLogExceptionBacktrace;

		if ( !( $e instanceof MWException ) || $e->isLoggable() ) {
			$log = self::getLogMessage( $e );
			if ( $wgLogExceptionBacktrace ) {
				wfDebugLog( 'exception', $log . "\n" . $e->getTraceAsString() . "\n" );
			} else {
				wfDebugLog( 'exception', $log );
			}
		}
	}