package org.apache.logging.log4j.core.jackson;

import com.fasterxml.jackson.databind.Module.SetupContext;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
import org.apache.logging.log4j.core.impl.ThrowableProxy;

class Initializers {
   static class SimpleModuleInitializer {
      void initialize(SimpleModule simpleModule) {
         simpleModule.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
         simpleModule.addDeserializer(ThreadContext.ContextStack.class, new MutableThreadContextStackDeserializer());
      }
   }

   static class SetupContextInitializer {
      void setupModule(SetupContext context) {
         context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
         context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
         context.setMixInAnnotations(Level.class, LevelMixIn.class);
         context.setMixInAnnotations(LogEvent.class, LogEventMixIn.class);
         context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
         context.setMixInAnnotations(ThrowableProxy.class, ThrowableProxyMixIn.class);
      }
   }
}
