// Path: layout/src/main/java/com/vlkan/log4j2/logstash/layout/util/JsonGenerators.java
// public enum JsonGenerators {;
// 
//     private static final class DoubleWriterContext {
// 
//         private static final int MAX_BUFFER_LENGTH =
//                 String.format("%d.%d", Long.MAX_VALUE, Integer.MAX_VALUE).length()
//                         + 1;
// 
//         private final StringBuilder builder = new StringBuilder();
// 
//         private char[] buffer = new char[MAX_BUFFER_LENGTH];
// 
//     }
// 
//     private static final ThreadLocal<DoubleWriterContext> DOUBLE_WRITER_CONTEXT_REF =
//             Constants.ENABLE_THREADLOCALS
//                     ? ThreadLocal.withInitial(DoubleWriterContext::new)
//                     : null;
// 
//     public static void writeDouble(JsonGenerator jsonGenerator, long integralPart, int fractionalPart) throws IOException {
//         if (fractionalPart < 0) {
//             throw new IllegalArgumentException("negative fraction");
//         } else if (fractionalPart == 0) {
//             jsonGenerator.writeNumber(integralPart);
//         } else if (Constants.ENABLE_THREADLOCALS) {
//             DoubleWriterContext context = DOUBLE_WRITER_CONTEXT_REF.get();
//             context.builder.setLength(0);
//             context.builder.append(integralPart);
//             context.builder.append('.');
//             context.builder.append(fractionalPart);
//             int length = context.builder.length();
//             context.builder.getChars(0, length, context.buffer, 0);
//             // jackson-core version >=2.10.2 is required for the following line
//             // to avoid FasterXML/jackson-core#588 bug.
//             jsonGenerator.writeRawValue(context.buffer, 0, length);
//         } else {
//             String formattedNumber = "" + integralPart + '.' + fractionalPart;
//             jsonGenerator.writeNumber(formattedNumber);
//         }
//     }
// 
//     /**
//      * Writes given object, preferably using GC-free writers.
//      */
//     public static void writeObject(JsonGenerator jsonGenerator, Object object) throws IOException {
// 
//         if (object == null) {
//             jsonGenerator.writeNull();
//             return;
//         }
// 
//         if (object instanceof String) {
//             jsonGenerator.writeString((String) object);
//             return;
//         }
// 
//         if (object instanceof Short) {
//             jsonGenerator.writeNumber((Short) object);
//             return;
//         }
// 
//         if (object instanceof Integer) {
//             jsonGenerator.writeNumber((Integer) object);
//             return;
//         }
// 
//         if (object instanceof Long) {
//             jsonGenerator.writeNumber((Long) object);
//             return;
//         }
// 
//         if (object instanceof BigDecimal) {
//             jsonGenerator.writeNumber((BigDecimal) object);
//             return;
//         }
// 
//         if (object instanceof Float) {
//             jsonGenerator.writeNumber((Float) object);          // Not GC-free!
//             return;
//         }
// 
//         if (object instanceof Double) {
//             jsonGenerator.writeNumber((Double) object);         // Not GC-free!
//             return;
//         }
// 
//         if (object instanceof byte[]) {
//             jsonGenerator.writeBinary((byte[]) object);
//             return;
//         }
// 
//         jsonGenerator.writeObject(object);
// 
//     }
// 
// }


import java.util.regex.Pattern;
import com.fasterxml.jackson.core.JsonGenerator;
import com.vlkan.log4j2.logstash.layout.util.JsonGenerators;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.time.Instant;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.datetime.FastDateFormat;
import java.io.IOException;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
                    FormatResolverContext.fromEventResolverContext(eventResolverContext);
        }

        @Override
        FormatResolverContext acquireContext() {
            lock.lock();
            return formatResolverContext;
        }

        @Override
        void releaseContext() {
            lock.unlock();
        }

    }

    private static EventResolver createFormatResolver(EventResolverContext eventResolverContext) {
        return Constants.ENABLE_THREADLOCALS
                ? new ThreadLocalFormatResolver(eventResolverContext)
                : new LockingFormatResolver(eventResolverContext);
    }

    private static final EventResolver SECS_LONG_RESOLVER = (logEvent, jsonGenerator) -> {
        Instant logEventInstant = logEvent.getInstant();
        long epochSecs = logEventInstant.getEpochSecond();
        jsonGenerator.writeNumber(epochSecs);
    };

    private static final EventResolver SECS_DOUBLE_RESOLVER = (logEvent, jsonGenerator) -> {
        Instant logEventInstant = logEvent.getInstant();
// Path: layout/src/main/java/com/vlkan/log4j2/logstash/layout/util/JsonGenerators.java
// public enum JsonGenerators {;
// 
//     private static final class DoubleWriterContext {
// 
//         private static final int MAX_BUFFER_LENGTH =
//                 String.format("%d.%d", Long.MAX_VALUE, Integer.MAX_VALUE).length()
//                         + 1;
// 
//         private final StringBuilder builder = new StringBuilder();
// 
//         private char[] buffer = new char[MAX_BUFFER_LENGTH];
// 
//     }
// 
//     private static final ThreadLocal<DoubleWriterContext> DOUBLE_WRITER_CONTEXT_REF =
//             Constants.ENABLE_THREADLOCALS
//                     ? ThreadLocal.withInitial(DoubleWriterContext::new)
//                     : null;
// 
//     public static void writeDouble(JsonGenerator jsonGenerator, long integralPart, int fractionalPart) throws IOException {
//         if (fractionalPart < 0) {
//             throw new IllegalArgumentException("negative fraction");
//         } else if (fractionalPart == 0) {
//             jsonGenerator.writeNumber(integralPart);
//         } else if (Constants.ENABLE_THREADLOCALS) {
//             DoubleWriterContext context = DOUBLE_WRITER_CONTEXT_REF.get();
//             context.builder.setLength(0);
//             context.builder.append(integralPart);
//             context.builder.append('.');
//             context.builder.append(fractionalPart);
//             int length = context.builder.length();
//             context.builder.getChars(0, length, context.buffer, 0);
//             // jackson-core version >=2.10.2 is required for the following line
//             // to avoid FasterXML/jackson-core#588 bug.
//             jsonGenerator.writeRawValue(context.buffer, 0, length);
//         } else {
//             String formattedNumber = "" + integralPart + '.' + fractionalPart;
//             jsonGenerator.writeNumber(formattedNumber);
//         }
//     }
// 
//     /**
//      * Writes given object, preferably using GC-free writers.
//      */
//     public static void writeObject(JsonGenerator jsonGenerator, Object object) throws IOException {
// 
//         if (object == null) {
//             jsonGenerator.writeNull();
//             return;
//         }
// 
//         if (object instanceof String) {
//             jsonGenerator.writeString((String) object);
//             return;
//         }
// 
//         if (object instanceof Short) {
//             jsonGenerator.writeNumber((Short) object);
//             return;
//         }
// 
//         if (object instanceof Integer) {
//             jsonGenerator.writeNumber((Integer) object);
//             return;
//         }
// 
//         if (object instanceof Long) {
//             jsonGenerator.writeNumber((Long) object);
//             return;
//         }
// 
//         if (object instanceof BigDecimal) {
//             jsonGenerator.writeNumber((BigDecimal) object);
//             return;
//         }
// 
//         if (object instanceof Float) {
//             jsonGenerator.writeNumber((Float) object);          // Not GC-free!
//             return;
//         }
// 
//         if (object instanceof Double) {
//             jsonGenerator.writeNumber((Double) object);         // Not GC-free!
//             return;
//         }
// 
//         if (object instanceof byte[]) {
//             jsonGenerator.writeBinary((byte[]) object);
//             return;
//         }
// 
//         jsonGenerator.writeObject(object);
// 
//     }
// 
// }


// Path: layout/src/main/java/com/vlkan/log4j2/logstash/layout/resolver/TimestampResolver.java
import java.util.regex.Pattern;
import com.fasterxml.jackson.core.JsonGenerator;
import com.vlkan.log4j2.logstash.layout.util.JsonGenerators;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.time.Instant;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.datetime.FastDateFormat;
import java.io.IOException;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;

                    FormatResolverContext.fromEventResolverContext(eventResolverContext);
        }

        @Override
        FormatResolverContext acquireContext() {
            lock.lock();
            return formatResolverContext;
        }

        @Override
        void releaseContext() {
            lock.unlock();
        }

    }

    private static EventResolver createFormatResolver(EventResolverContext eventResolverContext) {
        return Constants.ENABLE_THREADLOCALS
                ? new ThreadLocalFormatResolver(eventResolverContext)
                : new LockingFormatResolver(eventResolverContext);
    }

    private static final EventResolver SECS_LONG_RESOLVER = (logEvent, jsonGenerator) -> {
        Instant logEventInstant = logEvent.getInstant();
        long epochSecs = logEventInstant.getEpochSecond();
        jsonGenerator.writeNumber(epochSecs);
    };

    private static final EventResolver SECS_DOUBLE_RESOLVER = (logEvent, jsonGenerator) -> {
        Instant logEventInstant = logEvent.getInstant();
        JsonGenerators.writeDouble(