/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.fasterxml.jackson.core.JsonProcessingException
 *  com.fasterxml.jackson.databind.ObjectWriter
 */
package org.apache.logging.log4j.core.layout;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectWriter;
import java.nio.charset.Charset;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.layout.AbstractStringLayout;

abstract class AbstractJacksonLayout
extends AbstractStringLayout {
    protected static final String DEFAULT_EOL = "\r\n";
    protected static final String COMPACT_EOL = "";
    protected final String eol;
    protected final ObjectWriter objectWriter;
    protected final boolean compact;
    protected final boolean complete;

    protected AbstractJacksonLayout(ObjectWriter objectWriter, Charset charset, boolean compact, boolean complete) {
        super(charset);
        this.objectWriter = objectWriter;
        this.compact = compact;
        this.complete = complete;
        this.eol = compact ? COMPACT_EOL : DEFAULT_EOL;
    }

    @Override
    public String toSerializable(LogEvent event) {
        try {
            return this.objectWriter.writeValueAsString((Object)event);
        }
        catch (JsonProcessingException e) {
            LOGGER.error((Object)e);
            return COMPACT_EOL;
        }
    }
}
