private static void formatThrowableAsArray()

in ecs-logging-core/src/main/java/co/elastic/logging/EcsJsonSerializer.java [260:276]


    private static void formatThrowableAsArray(final StringBuilder jsonBuilder, final Throwable throwable) {
        final StringBuilder buffer = getMessageStringBuilder();
        final PrintWriter pw = new PrintWriter(new StringBuilderWriter(buffer), true) {
            @Override
            public void println() {
                flush();
                jsonBuilder.append("\t\"");
                JsonUtils.quoteAsString(buffer, jsonBuilder);
                jsonBuilder.append("\",");
                jsonBuilder.append(NEW_LINE);
                buffer.setLength(0);
            }
        };
        throwable.printStackTrace(pw);
        removeIfEndsWith(jsonBuilder, NEW_LINE);
        removeIfEndsWith(jsonBuilder, ",");
    }