View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.logging.log4j.core;
18  
19  import java.util.Collections;
20  import java.util.Map;
21  
22  import org.apache.logging.log4j.Level;
23  import org.apache.logging.log4j.Marker;
24  import org.apache.logging.log4j.ThreadContext;
25  import org.apache.logging.log4j.ThreadContext.ContextStack;
26  import org.apache.logging.log4j.core.impl.ThrowableProxy;
27  import org.apache.logging.log4j.message.Message;
28  import org.apache.logging.log4j.util.ReadOnlyStringMap;
29  
30  
31  /**
32   * An abstract log event implementation with default values for all methods. The setters are no-ops.
33   */
34  public abstract class AbstractLogEvent implements LogEvent {
35  
36      private static final long serialVersionUID = 1L;
37  
38      /**
39       * Subclasses should implement this method to provide an immutable version.
40       */
41      @Override
42      public LogEvent toImmutable() {
43          return this;
44      }
45  
46      @Override
47      public ReadOnlyStringMap getContextData() {
48          return null;
49      }
50  
51      /**
52       * Returns {@link Collections#emptyMap()}.
53       */
54      @Override
55      public Map<String, String> getContextMap() {
56          return Collections.emptyMap();
57      }
58  
59      @Override
60      public ContextStack getContextStack() {
61          return ThreadContext.EMPTY_STACK;
62      }
63  
64      @Override
65      public Level getLevel() {
66          return null;
67      }
68  
69      @Override
70      public String getLoggerFqcn() {
71          return null;
72      }
73  
74      @Override
75      public String getLoggerName() {
76          return null;
77      }
78  
79      @Override
80      public Marker getMarker() {
81          return null;
82      }
83  
84      @Override
85      public Message getMessage() {
86          return null;
87      }
88  
89      @Override
90      public StackTraceElement getSource() {
91          return null;
92      }
93  
94      @Override
95      public long getThreadId() {
96          return 0;
97      }
98  
99      @Override
100     public String getThreadName() {
101         return null;
102     }
103 
104     @Override
105     public int getThreadPriority() {
106         return 0;
107     }
108 
109     @Override
110     public Throwable getThrown() {
111         return null;
112     }
113 
114     @Override
115     public ThrowableProxy getThrownProxy() {
116         return null;
117     }
118 
119     @Override
120     public long getTimeMillis() {
121         return 0;
122     }
123 
124     @Override
125     public boolean isEndOfBatch() {
126         return false;
127     }
128 
129     @Override
130     public boolean isIncludeLocation() {
131         return false;
132     }
133 
134     @Override
135     public void setEndOfBatch(final boolean endOfBatch) {
136         // do nothing
137     }
138 
139     @Override
140     public void setIncludeLocation(final boolean locationRequired) {
141         // do nothing
142     }
143 
144     @Override
145     public long getNanoTime() {
146         return 0;
147     }
148 }