1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.jackson;
18
19 import org.apache.logging.log4j.Level;
20 import org.apache.logging.log4j.Marker;
21 import org.apache.logging.log4j.ThreadContext.ContextStack;
22 import org.apache.logging.log4j.core.LogEvent;
23 import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
24 import org.apache.logging.log4j.core.impl.ThrowableProxy;
25
26 import com.fasterxml.jackson.databind.Module.SetupContext;
27 import com.fasterxml.jackson.databind.module.SimpleModule;
28
29
30
31
32
33
34
35 class Initializers {
36
37
38
39
40 static class SetupContextInitializer {
41
42 void setupModule(final SetupContext context) {
43
44 context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
45
46 context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
47 context.setMixInAnnotations(Level.class, LevelMixIn.class);
48 context.setMixInAnnotations(LogEvent.class, LogEventMixIn.class);
49
50 context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
51 context.setMixInAnnotations(ThrowableProxy.class, ThrowableProxyMixIn.class);
52 }
53 }
54
55
56
57
58
59
60 static class SetupContextJsonInitializer {
61
62 void setupModule(final SetupContext context) {
63
64 context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
65
66 context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
67 context.setMixInAnnotations(Level.class, LevelMixIn.class);
68 context.setMixInAnnotations(LogEvent.class, LogEventJsonMixIn.class);
69
70 context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
71 context.setMixInAnnotations(ThrowableProxy.class, ThrowableProxyMixIn.class);
72 }
73 }
74
75
76
77
78 static class SimpleModuleInitializer {
79 void initialize(final SimpleModule simpleModule) {
80
81
82 simpleModule.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
83 simpleModule.addDeserializer(ContextStack.class, new MutableThreadContextStackDeserializer());
84 }
85 }
86
87 }