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;

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 ? "" : "\r\n";
   }

   public String toSerializable(LogEvent event) {
      try {
         return this.objectWriter.writeValueAsString(event);
      } catch (JsonProcessingException var3) {
         LOGGER.error((Object)var3);
         return "";
      }
   }
}
