@Override
    public void log(final Severity severity,
                    final Location location,
                    final String elementId,
                    final String message,
                    final ErrorType errorType,
                    final Throwable e) {
        final String msg = MessageUtil.getMessage(message, e);

        // Record the number of errors.
        StoredErrorStats stats = statsMap.get(severity);
        if (stats == null) {
            stats = new StoredErrorStats(Severity.FATAL_ERROR.equals(severity));
            statsMap.put(severity, stats);
        }
        stats.increment();

        // Only store this message for the current record if one hasn't been
        // stored already or if the new message is more severe.
        if (stats.getCurrentError() == null) {
            stats.setCurrentError(new StoredError(severity, location, elementId, msg, errorType));
        }

        // Do we need to write the error type?
        if (stats.getTotalCount() <= MAX_TOTAL_WRITTEN_MARKERS) {
            errorWriter.log(severity, location, elementId, msg);
        }
    }
Flags records that contain errors so that the RecordOutputFilter can exclude
them from the output.
stroom-pipeline/src/main/java/stroom/pipeline/errorhandler/RecordErrorReceiver.java