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  
29  
30  /**
31   * An abstract log event implementation with default values for all methods. The setters are no-ops.
32   */
33  public abstract class AbstractLogEvent implements LogEvent {
34  
35      private static final long serialVersionUID = 1L;
36  
37      /**
38       * Returns {@link Collections#emptyMap()}.
39       */
40      @Override
41      public Map<String, String> getContextMap() {
42          return Collections.emptyMap();
43      }
44  
45      @Override
46      public ContextStack getContextStack() {
47          return ThreadContext.EMPTY_STACK;
48      }
49  
50      @Override
51      public Level getLevel() {
52          return null;
53      }
54  
55      @Override
56      public String getLoggerFqcn() {
57          return null;
58      }
59  
60      @Override
61      public String getLoggerName() {
62          return null;
63      }
64  
65      @Override
66      public Marker getMarker() {
67          return null;
68      }
69  
70      @Override
71      public Message getMessage() {
72          return null;
73      }
74  
75      @Override
76      public StackTraceElement getSource() {
77          return null;
78      }
79  
80      @Override
81      public String getThreadName() {
82          return null;
83      }
84  
85      @Override
86      public Throwable getThrown() {
87          return null;
88      }
89  
90      @Override
91      public ThrowableProxy getThrownProxy() {
92          return null;
93      }
94  
95      @Override
96      public long getTimeMillis() {
97          return 0;
98      }
99  
100     @Override
101     public boolean isEndOfBatch() {
102         return false;
103     }
104 
105     @Override
106     public boolean isIncludeLocation() {
107         return false;
108     }
109 
110     @Override
111     public void setEndOfBatch(final boolean endOfBatch) {
112         // do nothing
113     }
114 
115     @Override
116     public void setIncludeLocation(final boolean locationRequired) {
117         // do nothing
118     }
119 
120 }