* @copyright © 2015 Bryan Davis and Wikimedia Foundation. */ class LineFormatter extends MonologLineFormatter { /** * @param string $format The format of the message * @param string $dateFormat The format of the timestamp: one supported by DateTime::format * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries * @param bool $ignoreEmptyContextAndExtra * @param bool $includeStacktraces */ public function __construct( $format = null, $dateFormat = null, $allowInlineLineBreaks = false, $ignoreEmptyContextAndExtra = false, $includeStacktraces = false ) { parent::__construct( $format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra ); $this->includeStacktraces( $includeStacktraces ); } /** * Convert an Exception to a string. * * @param Exception $e * @return string */ protected function normalizeException( Exception $e ) { $str = '[Exception ' . get_class( $e ) . '] (' . $e->getFile() . ':' . $e->getLine() . ') ' . $e->getMessage(); $prev = $e->getPrevious(); while ( $prev ) { $str .= ', [Exception ' . get_class( $prev ) . '] (' . $prev->getFile() . ':' . $prev->getLine() . ') ' . $prev->getMessage(); $prev = $prev->getPrevious(); } if ( $this->includeStacktraces ) { $str .= "\n[stacktrace]\n" . MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n"; } return $str; } }